Compiler program, a computer-readable storage medium storing a compiler program, a compiling method and a compiling unit

ABSTRACT

The present invention relates a compiler program, a computer-readable storage medium storing such a compiler program, a compiling method and a compiling unit, and an object thereof is to automatically generate a reentrant object program. In order to accomplish this object, an address saving program generator  16 a generates an address saving program for saving a data area address of a calling program module; an address setting program generator  16 b generates an address setting program for setting a data area address of an other program module; a transferring program generator  16 c generates a transferring program for the transfer from the calling program module to the other program module; an address resetting program generator  16 d generates an address resetting program for reading and resetting the saved data area address; and an accessing program generator  16 e generates an accessing program for accessing a data area for the other program module using a relative address from the set data area address.

TECHNICAL FIELD

The present invention relates to a compiler program for the conversion(also referred to as “translation” in some cases, but means the same) ofa source program (hereinafter, referred to as “source program codes” or“source codes”) written in a certain programming language into an objectprogram (hereinafter, referred to as “object code program” or “objectcodes”) executable in a certain computer, a computer-readable storagemedium storing a compiler program, a compiling method and a compilingunit.

The object program or the like mentioned in the specification of thepresent patent application contains, in addition to program codesdirectly executable in a computer, intermediate program codes which arethe first stage of the conversion into such program codes; intermediateprogram codes of a stage where actually accessible memory addresseswhich are decided in the program codes directly executable in thecomputer are not yet decided; and an intermediate code program of astage before the entire program codes directly executable in thecomputer are integrated.

The present invention also relates to a computer program for generatingan object program, a computer-readable storage medium storing a computerprogram, a compiling method and a compiling unit which conform to thepurpose of storing an object program in a limited memory area such as aso-called device installation program and storing an object program foran advanced and highly functional information processing in a limitedmemory like mobile information processings of recent years.

The present invention further relates to a computer program forautomatically generating an object program which can be reentered(hereinafter, also referred to as “reentrant” object program), acomputer-readable storage medium storing a computer program, a compilingmethod and a compiling unit.

BACKGROUND ART

Conventionally, function programs which are written on the conditions ofusing an operating system having time-division or priority preemptivetakes or a process scheduling function and a similar function, and afunction programming language, and which can be simultaneously calledfrom a plurality of tasks or processes within a specific time intervalhave been required to be reentrant.

Such reentrant function programs have been coded by human programmersand programs for automatically judging whether a possibility of reentryis satisfied have been written by them. Such a prior art technology isdisclosed, for example, in Japanese Unexamined Patent Publication No.2001-134431 (patent document 1).

A condition of satisfying the possibility of reentry has depended on thesyntax analysis of the entire source program describing functions to bejudged to extract the entire flow, the determination of scopes for allthe resources to be called in the entire flow and the judgment on thecompletely exclusive control according to the kind of the scope of theresource.

However, it is, in reality, very difficult due to a time restriction anda limit of the computer's processing ability to extract the entire flowby the syntax analysis of the entire source program, determine thescopes for the all the resources called in the entire flow and judgewhether or not the completely exclusive control is executed according tothe kind of the scope of the resource. Such a difficulty has obliged thejudgment to be made up to a certain level.

Since the conventional reentrant program has its essential portionwritten by human programmer, only incompletely exclusive controls can berealized while a huge amount of time is taken. This brings about manymaloperations when the program is executed.

Further, since such a reentrant program is frequently used in amulti-task and time-division environment, it has been quite difficult tofound out the cause of the maloperation. It has been even more difficultto renew and revise such a reentrant program.

SUMMARY OF THE INVENTION

The present invention was developed in order to solve the above problemsand an object thereof is to provide a computer program, acomputer-readable storage medium storing a computer program, a compilingmethod and a compiling unit which can automatically generate a reentrantobject program.

According to an aspect of the present invention, a source program isconverted into an object program by saving a data memory area addressused by a calling program module included in the source program, settinga data memory area address used by an other program module to be calledby the calling program module, executing transfer from a firstsubprogram included in the calling program module to a second subprogramincluded in the other program module, reading and resetting the saveddata memory area address for the calling program module after the returnfrom the second subprogram as a transfer end to the first subprogram,and accessing a data memory area for the other program module using arelative address from the set data memory area address for the otherprogram module when the other program module accesses the data memoryarea therefor included therein.

The object, features, aspects and advantages of the present inventionare rendered clear by the following detailed description and theaccompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram showing the construction of a dynamic module linksystem according to one embodiment of the invention,

FIG. 2 is a block diagram showing the construction of a compiling unitshown in FIG. 1,

FIG. 3 is a flow chart showing an exemplary compiling process by thecompiling unit shown in FIG. 2,

FIGS. 4A and 4B are diagrams showing configurations of a source programto be converted by the compiling unit and an object program obtained asa result of the conversion by the compiling unit according to a firstembodiment of the invention,

FIG. 5 is a block diagram showing the construction of a terminal unitshown in FIG. 1,

FIG. 6 is a flow chart showing a process in which an application programmodule calls a library program module via the terminal unit shown inFIG. 5,

FIGS. 7A and 7B are diagrams showing the process of calling the libraryprogram module from the application program module,

FIGS. 8A and 8B are diagrams showing exemplary source programs andobject programs of the application program module and the libraryprogram module,

FIGS. 9A and 9B are diagrams showing states of a stack,

FIGS. 10A and 10B are diagrams showing exemplary source program andobject program according to a second embodiment,

FIG. 11 is a block diagram showing the construction of a compiling unitaccording to a second embodiment of the invention,

FIG. 12 is a flow chart showing an exemplary compiling process by thecompiling unit shown in FIG. 11,

FIG. 13 is a diagram showing a code area and a data area of the libraryprogram module according to the second embodiment of the invention,

FIGS. 14A and 14B are diagrams showing exemplary source programs andobject programs of an application program module and a library programmodule according to a third embodiment of the invention,

FIGS. 15A and 15B are diagrams showing a code area and a data area ofthe library program module according to the third embodiment of theinvention,

FIGS. 16A, 16B and 16C are diagrams conceptually showing an applicationprogram module as a calling program to be converted by a compiler, alibrary program module as a program to be called, and an exemplarycalling process according to a fourth embodiment of the invention,

FIG. 17 is a block diagram showing the construction of a compiling unitaccording to a fifth embodiment of the invention,

FIG. 18 is a block diagram showing the construction of a terminal unitaccording to the fifth embodiment of the invention,

FIG. 19 is a flow chart showing an exemplary dynamic module linkingprocess by the terminal unit shown in FIG. 18,

FIG. 20 is a block diagram showing the constructions of the compilingunit and the terminal unit for solving a fragmentation,

FIG. 21 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving a fragmentation according to a firstmodification,

FIG. 22 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving a fragmentation according to a secondmodification,

FIGS. 23A, 23B and 23C are diagrams showing a method for solving thefragmentation in the second modification,

FIG. 24 is a diagram showing the construction of a compiling unit and aterminal unit for solving a fragmentation according to a thirdmodification,

FIGS. 25A, 25B and 25C are diagrams showing a method for solving thefragmentation in the third modification,

FIG. 26 is a diagram showing the construction of a compiling unit and aterminal unit for solving a fragmentation according to a fourthmodification, and

FIG. 27 is a block diagram showing the construction of a compiling unitand a terminal unit for solving a fragmentation according to a sixthmodification.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS OF THE INVENTION

Hereinafter, preferred embodiments of the present invention aredescribed with reference to the accompanying drawings.

First Embodiment

FIG. 1 is a diagram showing the construction of a dynamic module linkingsystem according to a first embodiment of the present invention. Adynamic module linking system shown in FIG. 1 is comprised of a server11 and a plurality of terminal units 12 (12 a, 12 b, 12 c, . . . ). Theserver 11 and the respective terminal units 12 are connected, forexample, via Internet. It should be noted that the terminal unit in thisembodiment is an object program executing unit for executing an objectprogram generated by the conversion of a source program. The objectprogram executing units include mobile communication terminals such asmobile phones and household electric appliances connected with a networksuch as Internet.

The terminal units in this embodiment receive the object program fromthe server 11 via a network such as Internet 13 and execute the receivedobject program. However, the present invention is not particularlylimited thereto. An object program generated by a compiling unit may besaved in a computer-readable storage medium such as a CD-ROM or DVD-ROM,the object program saved in the storage medium may be read by a storagemedium driving device provided in the terminal unit such as a CD-ROMdrive or a DVD-ROM drive, and the read object program may be executed.

The server 11 includes a compiling unit 14. The compiling unit 14converts a source program written by a programmer into an objectprogram. The terminal units 12 execute the object program converted bythe compiling unit 14.

FIG. 2 is a block diagram showing the construction of the compiling unit14 shown in FIG. 1. As shown in FIG. 2, the compiling unit 14 isprovided with a program executing unit 16 and a program storage 17.

The program executing unit 16 is constructed by, for example, a CPU(central processing unit) and includes an address saving programgenerator 16 a, an address setting program generator 16 b, atransferring program generator 16 c, an address resetting programgenerator 16 d, and an accessing program generator 16 e. The programstorage 17 includes a compiler program storage 17 a, a source programstorage 17 b and an object program storage 17 c.

The address saving program generator 16 a generates an address savingprogram for saving a data memory area address used by a calling programmodule contained in the source program.

The address setting program generator 16 b generates an address settingprogram for setting a data memory area address used by the other programmodule called by the calling program module.

The transferring program generator 16 c generates a transferring programfor the transfer from a first subprogram contained in the callingprogram module to a second subprogram contained in the other programmodule.

The address resetting program generator 16 d generates an addressresetting program for reading and resetting the saved data memory areaaddress for the calling program module after the return from the secondsubprogram as a transfer end to the first subprogram.

The accessing program generator 16 e generates an accessing program foraccessing the data memory area using a relative address from the datamemory area address for the other program module when the other programmodule accesses the data memory area therefor included in the otherprogram module.

The compiler program storage 17 a stores a compiler program forconverting a source program written beforehand into an object program.The source program storage 17 b stores the source program written, forexample, in C language, C++ language or the like. The source program iswritten not for the entire application, but module by module. The objectprogram storage 17 c stores the object program converted from the sourceprogram.

Next, a compiling process by the compiling unit shown in FIG. 2 isdescribed. FIG. 3 is a flow chart showing an exemplary compiling processby the compiling unit shown in FIG. 2.

In Step 1, the address saving program generator 16 a generates theaddress saving program for saving the leading address of a data area ofan application program module in a stack.

In Step S2, the address setting program generator 16 b generates theaddress setting program for setting the leading address of a data areaof a library program module.

In Step S3, the transferring program generator 16 c generates thetransferring program for the transfer from the application programmodule to the library program module.

In Step S4, the address resetting program generator 16 d generates theaddress resetting program for the reset to the leading address of thedata area of the application program module saved in the stack.

In Step S5, the accessing program generator 16 e generates the accessingprogram for accessing the data area using a relative address from theset leading address of the data area for the library program module whenthe library program module accesses the data area therefor containedtherein.

In this way, the address saving program, the address setting program,the transferring program, the address resetting program and theaccessing program which are generated by executing the compiler programare transmitted as the object programs to the respective terminal units12, which in turn execute the received object programs.

FIGS. 4A and 4B are diagrams showing the configurations of the sourceprogram to be converted by the compiling unit and the object programsobtained as a result of the conversion by the compiling unit accordingto the first embodiment of the invention, wherein FIG. 4A shows theconfiguration of the application program module and FIG. 4B shows theconfiguration of the library program module.

It should be noted that these programs do not always exist in anincorporated form, but may be separately saved in physical mediums orfiles.

These programs include application program modules 121, 131, a libraryprogram module 151, and several other program modules unillustratedbecause they are not directly related to the description of the presentinvention.

The program modules are obtained by dividing a program into certainunits (e.g. function units, link units, version-up units) and each havea program code area and an intrinsic data area. Here, although thelatter area is called the intrinsic data area, it may not be necessarilyintrinsic, strictly speaking, and may additionally have other certainpurpose and/or application. This applies also to the other description.

The program code area of the program module is an area for latching aprogram execution command and the like written in the program module.

The intrinsic data area of the program module is an area for latchingthe substances of external variables and static variables defined in theprogram module. Hereinafter, the external variables and the staticvariables are sometimes collectively referred to as external variables.

The application program module 121 includes a program code area 123, anintrinsic data area 125 of the application program module 121, andseveral other areas unillustrated because they are not directly relatedto the description of the present invention.

The application program module 131 includes a program code area 133, anintrinsic data area 135 of the application program module 131, andseveral other areas unillustrated because they are not directly relatedto the description of the present invention.

These application program modules 121, 131 are calling programs andcommonly call the library program module 151. Such a call is normallymade in the form of a function call, a subroutine call or the like. Thisis a program call 1 and a program call 2 (reentry) shown in FIG. 4.

These program modules normally include several subprograms, which arenormally functions, subroutines or the like. One of these functions andsubroutines may be called a program module.

Normally, the program module is called by calling the subprogram of theother program module. In some cases, the subprogram of the same programmodule may be called.

In a so-called multi-task environment or other environment where aplurality of processes, tasks or applications are executed or have to beexecuted in parallel in a time division manner, for example, theapplication program module 131 may call and execute the library programmodule 151 while the application program module 121 calls and executesthe library program module 151.

Such a state occurs countlessly in various information apparatuses.Several very simple examples are given here.

For example, in an apparatus having a mobile information communicationfunction such as a mobile phone, a user has to monitor whether or notthere has been any reception at the same time he inputs a data to betransmitted.

The data input and the reception can be monitored by another CPU, butthey needs to be done in parallel in a time division manner in order tobe done by one CPU to save the number of CPU to be used.

If a certain basic function subroutine is used both in the data inputapplication and the reception monitoring application, this functionsubroutine may be called from one application while being called andexecuted by the other.

A case where a plurality of tasks and the like call and execute the sameprogram module (function, subprogram, subroutine or the like) in atemporally overlapping manner is referred to as “reentry”. If a certainprogram module is configured to be called from a program executing aplurality of tasks in a temporally overlapping and parallel manner, thisprogram module is called to be “reentrant”.

Several methods for configuring the program module to be reentrant havebeen conventionally known.

A first method is to process everything using internal variables(hereinafter, also called local variables, which means the same asinternal variables) without using so-called external variables. Sincethe internal variables are newly secured in a stack area every time theprogram module is called and released simultaneously with the completionof the processing of this program module, accesses to the variables donot collide as long as only the internal variables are used. Thus, therehas been no problem in simultaneously executing the program module inparallel.

A second method employs so-called external variables and reconcilesaccesses to the external variables using a state variable calledsemaphore.

Since the external variables cannot be used according to the firstmethod, the transfer of the program module other than this program anddata may be sometimes restricted.

According to the second method, the semaphore has to be tested and setdespite its cumbersomeness every time an access is made to the externalvariable, thereby imposing much burden on a programmer and causingerrors and maloperations.

The library program module 151 includes a program code area 153,intrinsic data areas 155, 157 of the library program module 151, andseveral other areas unillustrated because they are not directly relatedto the description of the present invention.

The data areas 155, 157 are for the application program module 121 andfor the application program module 131, respectively, and aredistinguished by the original program module which called this libraryprogram module 151.

For example, when this library program module 151 is called from theapplication program module 121, the program code area 153 accesses thedata area 155 for the application program module 121 as an externalvariable area and executes the corresponding processing. When thelibrary program module 151 is called from the application program module131, the program code area 153 accesses the data area 157 for theapplication program module 131 as an external variable area and executesthe corresponding processing.

By separately using the intrinsic data areas used by the library programmodule, particularly the data areas used for the external variables, theprogram can be written without paying attention to the collision of theaccesses to the external variables.

As already described, there is no problem of the collision of accessesto the internal variables since the areas are secured in the stack areaevery time the library program module 151 is called.

Although the data area is prepared and used for each calling applicationprogram, the application programs mentioned here may be interpreted asapplication task units or may be thought to be of the same concept asapplication tasks.

The application programs mentioned here may also be interpreted asapplication process units or may be thought to be of the same concept asapplication processes.

A procedure of the process performed when the application program module121 calls the library program module 151 is described in more detailwith reference to FIGS. 5 to 8.

FIG. 5 is a block diagram showing the construction of the terminal unit12 shown in FIG. 1. FIG. 6 is a flow chart showing a process of theapplication program module 121 calling the library program module 151via the terminal unit 12 shown in FIG. 5. FIGS. 7A and 7B are diagramsshowing the process of calling the library program module from theapplication program module, wherein FIG. 7A shows a process of theapplication program module and FIG. 7B shows a process of the libraryprogram module. FIGS. 8A and 8B are diagrams showing exemplary sourceand object programs of the application program module and the libraryprogram module, wherein FIG. 8A shows the source program and the objectprogram of the application program module and FIG. 8B shows the sourceprogram and the object program of the library program module. The sourceprograms shown in FIGS. 8A and 8B are programs written in C language.

As shown in FIG. 5, the terminal unit 12 is provided with a programexecuting unit 18 and a memory 19. The program executing unit 18 isconstructed, for example, by a DSP (digital signal processor) andincludes an address saving device 18 a, an address setting device 18 b,a transferring device 18 c, an address resetting device 18 d, anaccessing device 18 e. The memory 19 includes an application programmodule storage 19 a, a library program module storage 19 b and a stack19 c.

The application program module storage 19 a saves the applicationprogram module transmitted from the compiling unit 14, the libraryprogram module storage 19 b saves the library program module transmittedfrom the compiling unit 14, and the stack 19 c temporarily saves dataand addresses during the process of calling a subroutine or a function.

The address saving device 18 a saves the leading address of theintrinsic data area 125 used by the calling application program module121 in the stack 19 c.

The address setting device 18 b sets the leading address of the dataarea 155 for the application program module of the library programmodule 151 called by the application program module 121.

The transferring device 18 c transfers from the program code area 123included in the application program module 121 to the program code area153 included in the library program module 151.

The address resetting device 18 d reads and resets the saved leadingaddress of the data area 125 for the application program module afterthe return from the program code area 153 of the transferred libraryprogram module 151 to the program code area 123 of the applicationprogram module 121.

The accessing device 18 e accesses the data area 155 using a relativeaddress from the set leading address of the data area 155 for thelibrary program module when the program code area 153 of the libraryprogram module 151 accesses the data area 155 for the library programmodule included in the library program module 151.

Here, when a “bar(A, B);” command written in the source program of theapplication program module 121 is converted into an object program, anobject program for calling a “bar” which is a function subroutine “bar”included in the library program module 151 (hereinafter, may be referredto as a function subprogram “bar” or merely referred to as a function“bar”, but mean the same) is generated (see 1 to 7 of FIG. 7A).

In Step S11 of FIG. 6, the address saving device 18 a saves a presentcontent of a DP (data point) register (hereinafter, sometimes merelyreferred to as “DP”) in the stack 19 c. The program included in theprogram code area 123 of the application program module 121 first savesthe contest of the DP register saving 0x0600(0600 in hexadecimalnotation, 0*16³+6*16²+0*16+0 when being converted in decimal notation,same below), which is the leading address of the intrinsic data area 125used by the application program module 121 presently being executed, inthe stack 19 c (see 1 in FIG. 7A and 1 in FIG. 8A).

This is to enable the application program module 121 to set the contentof the DP at 0x0600 again upon returning from the library program module151 and to use the intrinsic data area 125 for itself again. Althoughthe intrinsic data area is mentioned here, it may not be necessarilyintrinsic, strictly speaking, and may additionally have other certainpurpose and/or application. This applies also to the other description.

The DP register is an area for latching the leading address of the dataarea for the program module being executed. A special register isnormally prepared as this area. However, a generally used register maybe used without preparing any special register.

Next, in Step S12, the address saving device 18 a saves arguments of thefunction “bar” in the stack 19 c. Specifically, the program included inthe application program module 121 saves arguments A and B to betransferred to the library program module 151 (see 2 of FIG. 7A and 2 ofFIG. 8A).

Here, the state of the stack 19 c at this time is described. FIGS. 9Aand 9B are diagrams showing the states of the stack, wherein FIG. 9A isa concept diagram showing the state of the stack when the arguments Aand B are saved in the stack and FIG. 9B is a concept diagram showinghow to use the stack.

As shown in FIG. 9A, the stack (hereinafter, may also be referred to asa stack memory) 19 c is a memory area of the last-in/first-out type andsaves data necessary upon calling an other program module (e.g. afunction, a subroutine, a subprogram or the like) from a certain programmodule to use it in transferring data between the program modules, touse it as a memory area for local variable, to save an address to returnfrom the called function or the like to the calling program, and to useit for other purposes.

An address of an area of the stack 19 c where data are written and readis indicated by a register called a stack pointer (hereinafter, may alsobe merely referred to as a stack pointer or a stack pointer register).

How to use this stack 19 c is described with reference to FIG. 9B. Forexample, a local variable 2 saved at the third address from above of thestack shown in FIG. 9B can be accessed by changing the value of thestack point or by way of an indirect reference using the value of thestack pointer register minus 2 as an address.

Next, in Step S13, the address setting device 18 b sets a new DP.Specifically, the program included in the application program module 121reads an address (0x800) of the data area 155 for the applicationprogram module 121 which address is saved in an area within theintrinsic data area 125 of the application program module 121 and usedin the library program module 151 including the function “bar”, and setsthis address in the DP (see 3 of FIG. 7A and 3 of FIG. 8A).

The area for latching the address (0x800) of the data area 155 for theapplication program module 121 which address is used in the libraryprogram module 151 including the function “bar” is normally set by acompiler. However, this area may not necessarily be set by the compilerand may be prepared as a library and set at the time of a link.

Next, in Step S14, the transferring device 18 c calls a libraryfunction. The program included in the application program module 121saves an address used at the time of returning from the function “bar”as a called program to itself, i.e. an address of a command next to ajump command to the function “bar” in the stack 19 c and jumps to thefunction “bar” (see 4 of FIG. 7A and 4 of FIG. 8A).

As shown in FIG. 7B, the function “bar” as a called program is includedin the program code area 153 included in the library program module 151.This function “bar” is used to extract the arguments A and B saved inthe stack 19 c.

Further, in Step S15, the accessing device 18 e substitutes a value forthe external variable. The function “bar” uses, for example, an externalvariable C defined in the library program module 151 as an externalvariable. In the function “bar”, upon accessing the external variable Cand putting, for example, a value of 10 into its memory area, the valueof 10 is substituted for an address (0x850) which is a sum of the value(0x800) saved in the DP and a relative address (0x50). This commandformat is shown in 5 of FIG. 7B and 5 of FIG. 8B.

In this way, the function “bar” can access the data area 155 for theapplication program module 121 which is a memory area starting from theaddress (0x800).

Upon the completion of the process in the function “bar”, the control ofthe program is returned to the program included in the originalapplication program module 121.

Then, in Step S16, the address resetting device 18 d discards thearguments A, B of the function “bar” from the stack 19 c. Immediatelyafter the return from the function “bar”, the arguments A and B arediscarded from the stack 19 c (see 6 of FIG. 7A and 6 of FIG. 8A).Although the arguments are discarded immediately after the return fromthe function “bar” here, they may not be necessarily discardedimmediately thereafter, strictly speaking, and may be after a certainprocessing. This also applies to the other description.

Next, in Step S17, the address resetting device 18 d takes the originalvalue of the DP saved in the stack 19 c out of the stack 19 c and resetsit in the DP (see 7 of FIG. 7A and 7 of FIG. 8A).

In this way, the program included in the application program module 121at the calling side can access the intrinsic data area 125 of itselfagain.

At this time, since the value of the DP at the calling side is saved inthe bottommost address of the stack as shown in FIGS. 9A and 9B, thecalled library program module 151 needs not read the content of the DPand can actually execute all the necessary processings without readingit, whereby no unnecessary access needs to be made.

For example, in an other embodiment like a second embodiment followingbelow in which the saving of the value of DP in the stack can beselected, the same processing can be executed by an access to the sameaddress regardless of whether or not the value of the DP is saved in thestack by saving the value of the DP at the bottommost address of thestack. Thus, it is not necessary to separate the processings afterjudging whether or not the value of the DP is saved in the stack.

By saving the value of the DP at the bottommost address of the stack, astack position where necessary data such as arguments and returnaddresses are retrieved does not change at the side of the calledlibrary program module 151 regardless of whether or not the value of theDP is saved in the stack. In other words, since a relative position fromthe stack pointer of the stack for retrieving the arguments and thereturn addresses does not change, it is not necessary to retrieve thesearguments and return addresses in view of it.

Although the library program module is called from the applicationprogram module in this example, an other library program module may becalled from the library program module. Since the processings executedin such a case are same as those in the case of calling the otherlibrary program module from the application program module, nodescription is given thereon.

Although the other program module is called in this example, the sameprogram module can also be called. Since the processings executed insuch a case are same as those in the case of calling the other libraryprogram module, no description is given thereon.

In this way, even if the calling program module reenters the otherprogram module, the leading address of the intrinsic data area 125 usedby the application program module 121 can be retracted since it is savedin the stack, and the leading address of the data area 155 for theapplication program module 121 used by the library program module calledby the application program module 121 is set. Thus, the reentrant objectprogram can be generated to realize dynamic links between the modules.

Second Embodiment

In the first embodiment of the present invention, the object programgenerated by converting the command “bar(A,B);” written in the sourceprogram of the application program module 121 into the object programsaves the content of the DP register saving the leading address of theintrinsic data area 125 used by the application program module 121presently being executed in the stack; saves the arguments A, B, whichare data to be transferred to the library program module 151, in thestack; reads the address of the data area 155 for the applicationprogram module 121 used by the function “bar” to be called and sets thisaddress in the DP; saves the address at the time of returning from thefunction “bar” to itself in the stack; jumps to the function “bar”;discards the arguments A, B from the stack at the time of the returnfrom the function “bar”; and resets the original value saved in thestack in the DP.

In the second embodiment of the present invention to be described below,a description as to whether the above process is to be executed or apart of the process is to be deleted is included in the source programof the library program module 151.

Although the other program module is called in the above firstembodiment, a function “bar” within the same module is called in thesecond embodiment.

FIGS. 10A and 10B are diagrams showing exemplary source program andobject program according to the second embodiment, wherein FIG. 10Ashows an exemplary source program of a library program module and FIG.10B shows an exemplary object program of the library program module. Itshould be noted that the programs are written in C language. In thisexample, the language specification of C language is extended to add anew keyword “private” and a declaration is written by giving a qualifier“private” to a source code.

For example, the call of a function “bar” shown in FIG. 10 shows that apart of the process executed in the first embodiment can be deleted. Inthe function “bar” shown in FIG. 10A, a declaration to delete a part ofthe process is written, for example, in “private void bar (int A, intB).

As shown in FIG. 10A, the function “bar” included in the source programof the library program module includes a description that the function“bar” is “private”.

This description is to declare that “the function “bar” is a so-calledprivate function”, and is sometimes called, for example, a “privatedeclaration” or a “private function declaration.”

In the case that the presence of a description to call this privatefunction “bar”, there is not generated such an object program asdescribed in the first embodiment to save the value of the DP used bythe calling program module, to set the value of the DP indicating theaddress of the intrinsic data area used by the program module to becalled and to reset the value of the DP to the original one saved in thestack at the time of the return from the function “bar”.

FIG. 11 is a block diagram showing the construction of a compiling unit14 according to the second embodiment of the present invention. Thecompiling unit 14 shown in FIG. 11 is provided with a program executingunit 16 and a program storage 17.

The program executing unit 16 is constructed by, for example, a CPU(central processing unit) and includes an address saving programgenerator 16 a, an address setting program generator 16 b, atransferring program generator 16 c, an address resetting programgenerator 16 d, an accessing program generator 16 e, and a declarationdiscriminator 16 f. The program storage 17 includes a compiler programstorage 17 a, a source program storage 17 b and an object programstorage 17 c.

It should be noted that the same elements of the compiling unit of thesecond embodiment shown in FIG. 11 as those of the compiling unit of thefirst embodiment shown in FIG. 1 are identified by the same referencenumerals and only a construction different from the first embodiment isdescribed below.

The declaration discriminator 16 f judges whether or not to shorten theprocess in accordance with the description of a program code area of thelibrary program module called from a program code area included in theapplication program module included in the source program. In otherwords, the declaration discriminator 16 f discriminates whether or notthe aforementioned private declaration is included in the description ofthe source program.

Here, if the declaration discriminator 16 f judges not to shorten theprocess, i.e. if it discriminates that the private declaration is notincluded, the process by the address saving program generator 16 a, theaddress setting program generator 16 b, the transferring programgenerator 16 c, the address resetting program generator 16 d and theaccessing program generator 16 e perform the process similar to thefirst embodiment.

Further, if the declaration discriminator 16 f judges not to shorten theprocess, i.e. if it discriminates that the private declaration isincluded, the transferring program generator 16 c generates atransferring program for the transfer from the program code areaincluded in the application program module to the program code areaincluded in the library program module, and the accessing programgenerator 16 e generates an accessing program for accessing a data areafor the library program module included in the library program moduleusing a relative address from the leading address of this data area whenthe program code area included in the library program module accessesthis data area.

FIG. 12 is a flow chart showing an exemplary compiling process by thecompiling unit 14 shown in FIG. 11.

In Step S21, the declaration discriminator 16 f judges whether or notthe private declaration is included in the description of the programcode area of the library program module. Step S22 follows if the privatedeclaration is judged not to be included (NO in Step S21), whereas StepS27 follows if it is judged to be included (YES in Step S21).

The processings from Step S22 to Step S26 are not described since theyare same as those from Step S1 to Step S5 shown in FIG. 3. Further, theprocessing in Step S27 is not described, either, since it is same as theone in Step S3 shown in FIG. 3.

In Step S28, the accessing program generator 16 e generates theaccessing program for accessing the data area for the library programmodule included in the library program module using the relative addressfrom the leading address of this data area when the program code areaincluded in the library program module accesses this data area.

FIG. 13 is a diagram showing a code area and a data area of the libraryprogram module according to the second embodiment. When the descriptionto call the private function “bar” is made in the program code area 153of the library program module 151, an object program for executing astep of saving arguments A, B, which are data to be used in the function“bar”, in the stack to transfer them to the function “bar”, a step ofsaving an address (return address) of a command next to a command tojump to the function “bar” in the stack and jumping to the function“bar”, and a step of discarding the arguments A, B from the stack at thetime of the return from the function “bar” is generated by the compilingunit of this embodiment as shown in FIG. 11.

Thus, in cases where the calling program module and the program moduleto be called need not necessarily use different data areas, theexecution of the object program can be speeded up by making the privatedeclaration for the function “bar” to delete the steps of saving,setting and resetting the value of the DP, and the object program sizecan be made smaller since the unnecessary steps are not performed.

Upon the execution of such a private-declared function “bar”, thecontent of the DP does not change while being left at the state in theprogram module as a calling program as shown in FIG. 11. Thus, when thereadout of the data or the like is, for example, executed for anexternal variable C, the intrinsic data area (intrinsic data area 155 inthis case) of the calling program module is accessed.

Although not shown, it is not necessary to, for example, reset the valueof the DP, either, at the time of the return from the declared privatefunction “bar” to the calling program.

In the embodiment described thus far, the private function is declaredand a series of processings including the saving of the value of the DPare not performed, for example, if “private” is described before thefunction “bar” If no particular description is made, the function “bar”is not a private function and the processings of saving the value of theDP and the like are performed.

However, in another embodiment, a description “public” or the like canbe given to explicitly indicate that the function is not privatefunction.

Such a description is sometimes called a “public declaration” or a“public function declaration”. A series of processings including thesaving of the value of the DP can be explicitly indicated by giving thisdescription.

In still another embodiment, a function to which this “privatedeclaration” is given may be a function which is called or can be calledonly within the same program module. In further another embodiment, afunction to which this “private declaration” is given may be a functionwhich is called or can be called only between different program modules.

Although C language is extended by adding new keywords “private” and“public” to give declarations in this example, declarations may be givenwithout extending the use of the language, by using pragmatics or thelike. Alternatively, declarations may be described as separate files ordesignated as arguments of a compiler.

In this way, since whether or not to shorten the process isdiscriminated in accordance with the description of the program codearea of the library program module called from the program code areaincluded in the application program module, the execution of the objectprogram can be speeded up by deleting the processings of saving, settingand resetting the address, and the object program size can be madesmaller by performing no unnecessary processing in cases where theapplication program module and the library program module need notnecessarily use different data areas.

Further, since the description of the program code area of the libraryprogram module is a declaration described for each program code area,the processings of saving, setting and resetting the address can bedeleted depending on the processing content of the program code area ofthe library program module based on the presence or absence of thisdeclaration. Therefore, the execution of the object program can bespeeded up.

Third Embodiment

In the first embodiment, all the external variables (e.g. C) used by thefunction “bar” are accessed using an address obtained by adding therelative address (e.g. 0x50) from the DP to the value (e.g. 0x800) savedin the DP.

As a result, the function “bar” can use the intrinsic data area 155 forthe application program module 121, which is the memory area whosestarting address is, for example, 0x800, as an area for all the externalvariables to be used.

However, in a third embodiment of the present invention to be describednext, the source program of, for example, the function “bar” can includea description relating to a data memory area commonly accessed by aplurality of application program modules for calling, for example, thefunction “bar” in its variable declaring portion.

FIGS. 14A and 14B are diagrams showing exemplary source program andobject program according to the third embodiment, wherein FIG. 14A showsan exemplary source program of a library program module according to thethird embodiment and FIG. 14B shows an exemplary object program of thelibrary program module according to the third embodiment.

In FIGS. 14A and 14B, a declaration is written in C language. In thisexample, the language specification of C language is extended to add anew keyword “common” and a declaration is described by giving thisqualifier “common” to a source code.

For example, in a program of a function “bar” shown in FIGS. 14A, D andC are used as external variables used by the function “bar”. Thesedeclarations are, for example, descriptions “common int D;” and “int C;”shown in FIG. 14A.

The description “common int D;” declares that the external variable D isan external variable commonly accessed by a plurality of callingapplication programs to call the function “bar”.

Although the declarations are given by adding the new keyword “common”to extend C language in this example, they may be given withoutextending the language specification, by using pragmatics or the like.

Alternatively, declarations may be described as separate files ordesignated as arguments of a compiler.

As shown in FIG. 14A, the external variable D included in the sourceprogram of the application program module includes a description thatthis external variable D is “common”. This description is to declarethat “the external variable D is a so-called common external variable”and is sometime called, for example, a “common declaration” or a “commonexternal variable declaration”.

FIGS. 15A and 15B are diagrams showing a code area and a data area ofthe library program module according to the third embodiment.

FIG. 15A shows that a program code area 553 corresponds to a reentrantfunction “bar” and both a data area 555 for an application programmodule 121, which is an intrinsic data area, and a common data area 559are accessed from this program. Although the term “common data area” isused here, this area needs not be commonly used for other certainpurpose or application, strictly speaking, and may not be used for othercertain purpose or application. This also applies to the otherdescription.

FIG. 15B shows in more detail that the external variable C is saved inthe data area 555 for the application program module 121 which area isan intrinsic data area, and the external variable D is saved in thecommon data area 559 accessed by a common data area access.

The description “int C;” of FIG. 14A is to declare that the externalvariable C uses an intrinsic memory area for each of a plurality ofcalling application program modules to call the function “bar”. By thisdescription, the external variable C is saved in the intrinsic data area555 for the application program module (the program module 121 in thisexample) accessed by an intrinsic data area access as shown in FIG. 15B.

In the function “bar”, when the external variable C saved in theintrinsic data area 555 for each of the calling application programs(e.g. the program module 121 in this example) is accessed to, forexample, substitute a value of 10 for the external variable C in thismemory area, this value of 10 is substituted at an address obtained byadding a relative address (e.g. 0x50) from the DP to the value saved inthe DP (e.g. 0x800). This command format is shown in FIGS. 14B and 15B.The command format at this time is same as in the first embodiment.

As shown in FIG. 15B, the function “bar” can access the intrinsic dataarea 555 for the application program module 121 which is a memory areastarting, for example, from the address 0x800. The function “bar” issimultaneously called by a plurality of application program modules(e.g. the application program module 121 and the application programmodule 131 of FIG. 4A). Even if the reentry occurs as a result, accessesto the external variables do not collide.

The description “common int D;” of FIG. 14A is to declare that theexternal variable D uses the memory area commonly used by a plurality ofcalling application programs to call the function “bar”. By thisdescription, the external variable D is saved in the common data area559 commonly used by a plurality of application program modules andaccessed by a common data area access as shown in FIG. 15B.

In the function “bar”, when the external variable D saved in the commondata area 559 commonly used by the calling application programs (e.g.the program module 121) to, for example, substitute a value of 20 forthe external variable D in this memory area, this value of 20 issubstituted at an address obtained by adding a relative address (e.g.0x60) from a special register SDP to a value (e.g. 0xF00) saved in thespecial register SDP. This common format is shown in FIGS. 14B and 15B.

This SDP is a special register for saving the leading address of onecommon data area for all the program modules. The leading address ofthis common data area for all the application programs, which address isthe value saved in the SDP, is itself called SDP sometimes.

In another embodiment, a generally used register may be used as this SDPwithout using a special register as such. Such an embodiment isparticularly effective in an MPU (micro processing unit) provided withmany generally used registers and is even more effective in an MPU inwhich this generally used register can be used as an offset address fora memory access.

In still another embodiment, an ordinary memory or stack may be used asthe SDP without using a special register or a generally used register assuch.

However, in such an embodiment, several processings may be necessary fora memory access using the SDP saved in the stack or the ordinary memoryas an offset address.

These processings include, for example, a processing of reading the SDPsaved in the stack or memory and saving it in a register usable as anoffset address for a memory access and a processing of retracting thepresent content of the register as a preparation for the formerprocessing.

By accessing the memory area using the value saved in the SDP registeras an offset address in these methods, the function “bar” can access thecommon data area 559 for the application program modules, which is amemory area starting, for example, from the address 0xF00 as shown inFIG. 7B.

Although the value of the SDP is not shown, it may be saved in theintrinsic data area 125 similar to the intrinsic data area address ofthe library program module 151 as shown in FIG. 7A and may be saved andset during a processing of calling the library program module 151 fromthe application program module 121.

For example, the present SDP can be saved in the stack before thepresent DP (0x0600) is saved in the stack in Step S1 of FIG. 3.

Further, a new SDP (0x0F00) can be set before the new DP (0x0880) is setin Step S2 of FIG. 3.

By saving the present SDP in the stack before the arguments A, B aresaved in the stack in this way, the presence or absence of the SDP savedin the SDP does not concern the library program module to be called.Since this is same as in the first embodiment, no detailed descriptionis given here.

In such an embodiment, when the function “bar” is simultaneously calledfrom a plurality of application program modules (e.g. the applicationprogram module 121 and the application program module 131 of FIG. 4A)and the reentry occurs as a result, it is explicit that the data can becommonly used and transferred and applied to other processings commonlyusing some of the external variables.

At this time, a reconciliation using the aforementioned semaphore or thelike may be made or may have to be made. However, since it is notdirectly related to the content of the present invention, no descriptionis given thereon.

As described above, even if the library program module is called from aplurality of application program modules, no collision occurs, forexample, in the accesses to the external variables since the executionintrinsic data memory areas provided for the respective applicationprogram modules are accessed. Thus, the program module can be configuredto be reentrant. Further, even if the library program module is calledfrom a plurality of application program modules, some of the externalvariables can be, for example, commonly used since the execution commondata memory area commonly used by the respective application programmodules is accessed.

The description for specifying which of the execution common data memoryarea for the library program module and the execution intrinsic datamemory area for the library program module is to be used is a commondeclaration described for each external variable included in the libraryprogram module. Thus, the execution common data memory area and theexecution intrinsic data memory area can be easily properly used byjudging the presence or absence of the common declaration.

Fourth Embodiment

FIGS. 16A, 16B and 16C are diagrams conceptually showing an exemplaryapplication program module 121 which is a calling program to beconverted by a compiler, an exemplary library program module 151 to becalled, and an exemplary process performed at the time of calling thelibrary program module 151 according to a fourth embodiment of thepresent invention. Specifically, FIG. 16A shows an exemplary tablesaving addresses of intrinsic data areas of each program module, FIG.16B shows an exemplary code area and an exemplary data area of theapplication program module according to the fourth embodiment and FIG.16C shows an exemplary code area and an exemplary data area of thelibrary program module according to the fourth embodiment.

As shown in FIG. 16A, in the fourth embodiment, the table storingaddresses of the intrinsic data areas of each program module called aCCT (context control table) is provided for each calling applicationprogram module, for each calling application program, for each callingapplication process, for each calling process, for each calling task,for each calling application, for each calling process or for eachcalling task.

In the calling application program module 121, an intrinsic data area125 for the application program module 121 is used by referring to theCCT for the application program module 121 to read out “0x600” which isan address of the data area of the application program module 121itself, setting this value in a DP, and accessing an external variableusing this value as an offset address.

In order to call a function “bar” included in the library program module151 from this application program module 121, arguments A, B to betransferred to the function “bar” are first saved in a stack.

Subsequently, in the application program module 121, an address used toreturn from the function “bar” to the application program module 121itself, i.e. an address next to a jump command to jump to the function“bar” is saved in the stack and a control is switched over to thefunction “bar”.

In the function “bar” which is included in the library program module151 to be called and to which the control was switched over, a presentcontent of the DP is saved. The present content of the DP is a value ofthe intrinsic data address for the calling application program module121. This value is saved to be reset in the DP for the use of theintrinsic data area for the application program module 121 at the timeof the return from the function “bar” to the calling program.

Subsequently, a pointer address for the CCT for the application programmodule 121 is read out by referring to the content of the DP; the CCTfor the application program module 121 is read out by referring to thispointer address; and an address (0x800 in this example) of a data area155 for the application program module 121 intrinsically used by theapplication program module 121 in the function “bar” is read out and setin the DP register.

In the function “bar” included in the library program module 151 calledby the application program module 121, the value of the DP register isused as a base address of a relative address upon an access to anexternal variable. Thus, all the external variables used by the function“bar” are accessed using 0x800 as the base address of the relativeaddress, and the data area 155 for the application program module 121 isallotted as long as the library program module 151 is called from theapplication program module 121.

Thus, accesses to the external variables do not collide even if thefunction “bar” experiences reentry upon being called by a plurality ofapplication program modules.

At the time of returning from the function “bar” to the callingapplication program module 121, the content of the DP is reset to thesaved value of the intrinsic data area address for the callingapplication program module 121 and the return is made.

Thus, in the calling application program module 121, its data area canbe used again.

In the fourth embodiment, since the DP is not set at the library programmodule 151 to be called, the size of the object program at the calledside can be made smaller, which is particularly effective in the casethat the library program module 151 is frequently called.

In this way, even if the reentry of the application program modules tothe library program module occurs, no collision occurs, for example, inaccesses to the external variables since accesses are made via thetables (CCT) storing the leading addresses of the data memory areas ofthe respective program modules. Thus, the program module can beconfigured to be reentrant.

Although not shown, if a “private declaration” is given for the function“bar” in FIG. 16C, the aforementioned processings of saving the value ofthe DP and setting the value of the DP for the function “bar” used uponbeing called from the application program module 121 by reading it outfrom the CCT are not performed as in the second embodiment. If a“public” declaration is given, the aforementioned processings of savingthe value of the DP and setting the value of the DP for the function“bar” used upon being called from the application program module 121 byreading it out from the CCT are explicitly performed. Since these aresame as in the second embodiment, no description is given thereon.

In this case, whether or not to shorten the process is discriminatedbased on the description of the program code area included in thelibrary program module called from the program code area included in theapplication program module. Accordingly, in cases where the applicationprogram module and the library program module to be called need notnecessarily use different data areas, the processing of setting theleading address via the tables (CCT) storing the leading addresses ofthe data areas for the respective program modules can be deleted,thereby speeding up the execution of the object program. The size of theobject program can be made smaller by not performing the unnecessaryprocessing.

Although not shown, instead of saving not only the value of the DP, butalso the value of the new SDP (0x0F00) described in the third embodimentin the intrinsic data area 125 of FIG. 7A and saving and setting them inthe program code area 123 of the calling program module 121, a tablesimilar to the CCT of FIG. 16A may be, for example, prepared; theleading address of the common data area for the respective programmodules may be saved in this table; the table similar to the CCT and thevalue of the SDP saved in this table are read and set during theprocessing, for example, in the program code area 153 of the libraryprogram module 151 of FIG. 16C which is a library program module to becalled. Since this is same as the saving and setting of the value of theDP mentioned above, no description is given thereon. Unlike the CCT, thetable similar to the CCT may possess only one execution environment.

Fifth Embodiment

Next, a fifth embodiment of the present invention is described. In thefifth embodiment, identification numbers are given to program modules; atable corresponding the identification numbers and DPs of data areas ofthe respective program modules is prepared; the table is referred tousing the identification number of the program module as an index whenthe library program module is called from the application programmodule, thereby switching the DP in the data area of the library programmodule and the one in the data of the application program module.

FIG. 17 is a block diagram showing the construction of a compiling unitaccording to the fifth embodiment of the present invention. Thecompiling unit 14 shown in FIG. 17 is provided with a program executingunit 16 and a program storage 17.

The program executing unit 16 is constructed by, for example, a CPU(central processing unit) and includes an address saving programgenerator 16 a, an address setting program generator 16 bn, atransferring program generator 16 c, an address resetting programgenerator 16 d, an accessing program generator 16 e, anidentification-number designating program generator 16 g, a tablepreparing program generator 16 h, an identification-number obtainingprogram generator 16 i and a leading-address obtaining program generator16 j. The program storage 17 includes a compiler program storage 17 a, asource program storage 17 b and an object program storage 17 c.

The same elements of the compiling unit according to the fifthembodiment shown in FIG. 17 as those of the compiling unit according tothe first embodiment shown in FIG. 2 are identified by the samereference numerals, and only the construction different from the firstembodiment is described below.

The identification-number designating program generator 16 g generatesan identification-number designating program for designatingidentification numbers for identifying the calling program modules andthe one for identifying the other program module.

The table preparing program generator 16 h generates a table preparingprogram for relating the designated identification numbers of thecalling program modules and the leading addresses of data areas of thecalling program modules and relating the designated identificationnumber of the other program module and the leading address of data areaof the other program module.

The identification-number obtaining program generator 16 i generates anidentification-number obtaining program for obtaining the identificationnumber of the other program module upon a call command to the otherprogram module from the calling program module.

The leading-address obtaining program generator 16 j generates aleading-address obtaining program for obtaining the leading address ofthe data area of the other program module from the prepared table usingthe obtained identification number as an index.

FIG. 18 is a block diagram showing the construction of a terminal unitaccording to a fifth embodiment of the present invention. The terminalunit 12 shown in FIG. 18 is provided with a program executing unit 18, amemory 19, a data reader 20 and a communicator 21. The communicator 21saves a downloaded object program transmitted from a server 11 in thememory 19 and includes an identification-number designating device 21 a.The data reader 20 is adapted to read the object program downloaded bythe communicator 21 in the memory 19 and includes a DP table preparingdevice 20 a. The program executing unit 18 is constructed, for example,by a SDP or the like and includes an address saving device 18 a, anaddress setting device 18 b, a transferring device 18 c, an addressresetting device 18 d, an accessing device 18 e, anidentification-number obtaining device 18 g and a leading-addressobtaining device 18 h. The memory 19 includes an application programmodule storage 19 a, a library program module storage 19 b, a stack 19 cand a DP table storage 19 d.

The same elements of the terminal unit according to the fifth embodimentshown in FIG. 18 as those of the compiling unit according to the firstembodiment shown in FIG. 5 are identified by the same referencenumerals, and only the construction different from the first embodimentis described below.

The identification-number designating device 21 a designates theidentification numbers for identifying the application program modulesas the calling program modules to the application program modules andthe identification number for identifying the library program module asthe other program module to the library program module.

The DP table preparing device 20 a relates the identification numbers ofthe application program modules designated by the identification-numberdesignating device 21 a to the leading addresses (DPs) of the data areasof the application program modules and relates the identification numberof the library program module designated by the identification-numberdesignating device 21 a to the leading address (DP) of the data area ofthe library program module, and saves it in the DP table storage 19 d.

The identification-number obtaining device 18 g obtains theidentification number of the library program module upon the callcommand to the library program module from the application programmodule.

The leading-address obtaining device 18 h obtains the leading address ofthe data area of the library program module from the DP table generatedby the DP table preparing device 20 a using the identification numberobtained by the identification-number obtaining device 18 g as an index.

The address setting device 18 b sets the leading address of the dataarea used by the library program module to be called by the applicationprogram module at the leading address obtained by the leading-addressobtaining device 18 h.

The DP table storage 19 d saves the DP table generated by the DP tablepreparing device 20 a.

FIG. 19 is a flow chart showing an exemplary dynamic module linkingprocess by the terminal unit shown in FIG. 18.

In Step S31, the communicator 21 downloads the application programmodule converted from a source program into an object program by thecompiling unit 14 of the server 11 and the library program module.

In Step S32, the identification-number designating device 21 adesignates the intrinsic identification numbers to the downloadedapplication program module and library program module. Theidentification numbers designated by the identification-numberdesignating device 21 a are saved in the application program modulestorage 19 a and the library program module storage 19 b, respectively.

In Step S33, the data reader 20 reads the code areas of the applicationprogram module and the library program module.

In Step S34, the DP table preparing device 20 a generates the DP tablerelating the leading addresses of the data areas of the respectiveprogram modules and the identification numbers of the respective programmodules in the DP table storage 19 d of the memory 19. It should benoted that no data is yet inputted to the DP table and only an area issecured in the memory at this time.

In Step S35, the data reader 20 allots the data areas to the accessingprogram and the library program module. Specifically, the data areas ofthe application program module and the library program module are savedin the application program module storage 19 a and the library programmodule storage 19 b of the memory 19.

In Step S36, the DP table preparing device 20 a relates the leadingaddress (DP) of the data area of the application program module to theidentification number of the application program module saved in the DPtable storage 19 d, and relates the leading address of the data area ofthe library program module to the identification number of the libraryprogram module saved in the DP table storage 19 d.

In Step S37, the identification-number obtaining device 18 g judgeswhether or not the library program module has been called from theapplication program module. Here, Step S38 follows if the libraryprogram module is judged to have been called from the applicationprogram module, whereas a standby state is set until the library programmodule is called from the application program module if the libraryprogram module is judged not to have been called from the applicationprogram module.

In Step S38, the address saving device 18 a retracts the leadingaddresses of the code area and the data area of the application programmodule by saving them in the stack 19 c of the memory 19,

In Step S39, the identification-number obtaining device 18 g obtains theidentification of the library program module saved in the libraryprogram module storage 19 b.

In Step S40, the leading-address obtaining device 18 h refers to the DPtable saved in the DP table storage 19 d using the identification numberof the library program module obtained by the identification-numberobtaining device 18 g as an index and obtains the leading addresscorresponding to the identification number of the library programmodule.

In Step S41, the address setting device 18 b switches the leadingaddress of the data area of the application program module by settingthe leading address of the data area of the library program moduleobtained by the leading-address obtaining device 18 h.

In Step S42, the address resetting device 18 d restores the leadingaddresses of the code area and the data area of the application programmodule retracted to the stack 19 c of the memory 19 by the addresssaving device 18 b by resetting them.

In this way, first, the identification-number designating programgenerator 16 g generates the identification-number designating programfor designating the identification number for identifying theapplication program module and the one for identifying the libraryprogram module. Then, the table preparing program generator 16 hgenerates the table preparing program for preparing the table relatingthe designated identification number of the application program moduleand the leading address of the data area of the application programmodule and the designated identification number of the library programmodule and the leading address of the data area of the library programmodule. Upon the call command to the library program module from theapplication program module, the identification-number obtaining programgenerator 16 i generates the identification-number obtaining program forobtaining the identification number of the library program module. Theleading-address obtaining program generator 16 j generates theleading-address obtaining program for obtaining the leading address ofthe data area of the library program module from the prepared table,using the obtained identification number as an index. Further, theaddress setting program generator 16 b generates the leading-addressswitching program for switching the leading address of the data area ofthe application program module to the obtained leading address.

Accordingly, instead of preparing the table for the address conversionpage by page as in a conventional MMU (memory management unit), such atable can be prepared module by module, whereby an amount of the data ofthe table can be reduced to conform to small-size apparatuses having astrict resource restriction. Further, since the amount of the data ofthe table can be reduced, an execution speed can be increased ascompared to the address conversion by the conventional MMU.

The program executing unit 16 of the compiling unit 14 may be providedwith an address latching program generator for generating an addresslatching program for latching addresses to variables or functionsdefined outside the library program module, and the program executingunit 18 of the terminal unit 12 may be provided with an address latchingdevice for latching addresses to the variables or functions definedoutside the library program module. In this case, the accessing device18 e accesses a variable defined inside the library program module usinga relative address from the leading address obtained by theleading-address obtaining device 18 h while accesses a function definedinside the library program module using a relative address from a PC(program counter). Further, the accessing device 18 e indirectlyaccesses a variable or a function defined outside the library programmodule via the address latched by the address latching device afteraccessing the address latched by the address latching device using arelative address from the leading address obtained by theleading-address obtaining device 18 h.

With this configuration, the address latching program generatorgenerates the address latching program for latching the address to thevariable or function defined outside the library program module. Then,the accessing program generator 16 e generates the accessing program foraccessing the variable or function defined inside the library programmodule using the relative address from the obtained leading address,accessing the function defined inside the library program module usingthe relative address from the program counter, and indirectly accessingthe variable or function defined outside the library program module viathe address latched by the latched address latching device afteraccessing the latched address using the relative address from theobtained leading address. Accordingly, the variable or function definedoutside the library program module can be indirectly accessed via thelatched address.

In this embodiment, the terminal unit 12 downloads the table preparingprogram generated by the table preparing program generator 16 h providedin the compiling unit 14, whereby the data reader 20 functions as the DPtable preparing device 20 a, and the terminal unit 12 downloads theidentification-number designating program generated by theidentification-number designating program generator 16 g, whereby thecommunicator 21 functions as the identification-number designatingdevice 21 a. However, the data reader 20 may be provided with a functionas the DP table preparing device 20 a in advance and the communicator 21may be provided with a function as the identification-number designatingdevice 21 a in advance. In such a case, the program executing unit 16 ofthe compiling unit 14 shown in FIG. 17 only includes the address savingprogram generator 16 a, the address setting program generator 16 b, thetransferring program generator 16 c, the address resetting programgenerator 16 d, the accessing program generator 16 e, theidentification-number obtaining program generator 16 i and theleading-address obtaining program generator 16 j.

In this way, the identification-number obtaining program generator 16 igenerates the identification-number obtaining program for obtaining theidentification number for identifying the library program module uponthe call command to the library program module from the applicationprogram module. The leading-address obtaining program generator 16 jgenerates the leading-address obtaining program for obtaining theleading address of the data area of the library program module from thetable relating the identification number of the application programmodule to the leading address of the data area of the applicationprogram module and relating the identification number of the libraryprogram module to the leading address of the data area of the libraryprogram module. Then, the address resetting program generator 16 dgenerates the leading-address switching program for switching theleading address of the data area of the application program module tothe obtained leading address.

By preparing the table for the address conversion not page by page, butmodule by module, the amount of the data of the table can be reduced andthe table can conform to small-size apparatuses having a strict resourcerestriction. Further, a time required for the compiling process can beshortened and an amount of the data of the program module to betransmitted to the terminal units 12 can be reduced since the programfor designating the identification numbers and the one for preparing thetable need not be compiled.

Next, a method for solving a fragmentation is described. If data arerepeatedly written in and deleted from a memory, empty areas in thememory are fragmented and it becomes difficult to continuously save onedata in the memory. In such a case, one data has to be saved over aplurality of areas, leading to a reduction in an accessing speed to thememory. Thus, it is necessary to integrate the fragmented memory areasinto a continuous memory area.

FIG. 20 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving the fragmentation. It should be notedthat no description is given on the same elements as those of the otherembodiments by identifying them by the same reference numerals.

As shown in FIG. 20, a server 11 is provided with a communicator 22 anda compiling unit 14. The communicator 22 transmits an object programconverted by the compiling unit 14 to a terminal unit 12. The compilingunit 14 is provided with a program executing unit 16 and a programstorage 17. The program executing unit 16 includes an application endingprogram generator 23 a, a compaction program generator 23 b and anapplication resuming program generator 23 c.

The application ending program generator 23 a generates an endingprogram comprised of at least one program module and adapted to end anapplication being presently executed.

The compaction program generator 23 b generates a compaction program forcompacting a memory 19, i.e. applying a compaction to the memory 19after the application is ended. The compaction means to integratefragmented areas in the memory 19 into a continuous area.

The application resuming program generator 23 c generates a resumingprogram for resuming the ended application from the beginning after thememory 19 is compacted.

The terminal unit 12 is provided with a program executing unit 18, thememory 19 and a communicator 21. The communicator 21 receives the objectprogram transmitted from the server 11 and saved it in the memory 19.The program executing unit 18 includes an application ending device 24a, a compacting (compaction) device 24 b, and an application resumingdevice 24 c.

The application ending device 24 a is comprised of at least one programmodule, and ends the application being presently executed. Thecompacting device 24 b compacts the memory 18 after the application isended by the application ending device 24 a. The application resumingdevice 24 c resumes the application ended by the application endingdevice 24 a from the beginning after the memory 19 is compacted.

In this way, the application ending program generator 23 a generates theending program comprised of at least one module and adapted to end theapplication being presently executed. After the application is ended,the compaction program generator 23 b generates the compaction programfor compacting the memory 19. The application resuming program generator23 c generates the resulting program for resuming the application fromthe beginning after the memory 19 is compacted. Accordingly, thefragmentation of the memory can be solved, enabling the effective use ofthe memory.

Next, a first modification of the method for solving the fragmentationof the memory is described. In the first modification, the state of anapplication being presently executed is saved using such informationindependent of address values, and the application is executed in thesaved state after the compaction.

FIG. 21 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving the fragmentation according to the firstmodification. It should be noted that no description is given on thesame elements as those of the other embodiments by identifying them bythe same reference numerals.

As shown in FIG. 21, a server 11 is provided with a communicator 22 anda compiling unit 14. The compiling unit 14 is provided with a programexecuting unit 16 and a program storage 17. The program executing unit16 includes an application ending program generator 23 a, an applicationinformation saving program generator 23 d, a compaction programgenerator 23 b and an application executing program generator 23 e.

The application information saving program generator 23 d generates asaving program for saving such information independent of address valuesof the application until the application was ended.

The application executing program generator 23 e generates an executingprogram for reading the saved information after a memory 19 is compactedand executing the application up to a state where the application wasended based on the read information.

The terminal unit 12 is provided with a program executing unit 18, thememory 19 and a communicator 21. The program executing unit 18 includesan application ending device 24 a, an application information savingdevice 24 d, a compacting device 24 b, and an application executingdevice 24 c.

The application information saving device 24 d saves such informationindependent of the address values of the application until theapplication was ended by the application ending device 24 a. Theapplication executing device 24 e reads the information saved by theapplication information saving device 24 d after the memory 19 iscompacted and executes the application up to the state where theapplication was ended based on the read information.

In this way, the application ending program generator 23 a generates theending program comprised of at least one module and adapted to end theapplication being presently executed. Then, the application informationsaving program generator 23 d generates the application informationsaving program for saving the information independent of the addressesvalues of the application until the application was ended. Thecompaction program generator 23 b generates the compaction program forcompacting the memory 19. After the memory 19 is compacted, theapplication executing program generator 23 e generates the applicationexecuting program for reading the saved information and executing theapplication up to the state where the application was end based on theread information. Accordingly, the fragmentation of the memory can besolved, enabling the effective use of the memory.

Next, a second modification of the method for solving the fragmentationof the memory is described. In the second modification, an area of areference flag (identifier) is provided for each of all memory spaces;the case of setting an address value and the case of setting a valueother than the address value such as a numerical value can bediscriminated based on the reference flag; and relocation is made for anentry having the address value set based on the reference flag after thecompaction.

FIG. 22 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving the fragmentation according to thesecond modification. It should be noted that no description is given onthe same elements as those of the other embodiments by identifying themby the same reference numerals.

As shown in FIG. 22, a server 11 is provided with a communicator 22 anda compiling unit 14. The compiling unit 14 is provided with a programexecuting unit 16 and a program storage 17. The program executing unit16 includes a memory-state saving program generator 23 f, a compactionprogram generator 23 b and a relocating program generator 23 g.

The memory-state saving program generator 23 f generates a memory-statesaving program for saving the state (memory map) of a memory 19 beforethe compaction.

The relocating program generator 23 g generates a relocating program forrelocating an address value for an entry having the address value setbased on a reference flag for identifying the case of setting theaddress value and the case of setting a value other than the addressvalue such as a numeral value by referring to the saved state of thememory 19 before the compaction, after the memory 19 is compacted.

The terminal unit 12 is provided with a program executing unit 18, thememory 19 and a communicator 21. The program executing unit 18 includesa memory-state saving device 24 f, a compacting device 24 b, and arelocating device 24 g.

The memory-state saving device 24 f saves the state (memory map) of thememory 19 before the compaction. The relocating device 24 g relocatesthe address value for the entry having the address value set based onthe reference flag for identifying the case of setting the address valueand the case of setting a value other than the address value such as anumeral value by referring to the saved state of the memory 19 beforethe compaction, after the memory 19 is compacted.

FIGS. 23A, 23B and 23C are diagrams showing the method for solving thefragmentation according to the second modification, wherein FIG. 23Ashows a fragmented state of a memory before the compaction, FIG. 23Bshows a state of the memory after the compaction, and FIG. 23C shows astate of the memory after the relocation.

In the memory 19 shown in FIG. 23A, an area from 0x300 to 0x400 isunused; 0x558 which is an address value is saved at 0x500; a value of 3is saved at 0x554; a value of 100 is saved at 0x558; and an area from0x700 and above is unused; and other data are saved in other areas. Inthis modification, an area RF of the reference flag is provided for eachmemory space of the memory 19. In this area RF, “1” is set when theaddress value is set while “0” is set when a value other than theaddress value such as a numeral value is set. In FIG. 23A, the referenceflag is set at “1” at the address 0x550 since the address value of 0x558is set as a pointer variable there while being set at “0” at theaddresses 0x554, 0x558 since the numerical values 3, 100 are set there.

When the memory 19 of the state shown in FIG. 23A is compacted, thestate shown in FIG. 23B is attained. Specifically, as shown in FIG. 23B,the unused area from 0x300 to 0x400 disappears, an area from 0x100 to0x600 is integrated, and an area from 0x600 and above is an unused areain the memory 19. In this case, since the addresses in the memory 19 areshifted, the address 0x550 where the address value 0x558 was savedbefore the compaction is shifted to 0x450, and the address 0x558 pointedby the address 0x550 is shifted to 0x458. As a result, the addresspointed by the pointer variable saved at the address 0x450 disappears asshown in FIG. 23B.

Accordingly, the memory-state saving device 24 f saves the state of thememory 19 before the compaction, and the relocating device 24 gdiscriminates the value of the reference flag after the memory 19 iscompacted and relocates the address value for the entry having thereference flag set at “1” by referring to the saved memory state beforethe compaction and the state of the memory 19 after the compaction. Forexample, as shown in FIG. 23C, the address value saved at the address0x450 is relocated to a correct address value of 0x458 from 0x558.

In this way, the identifier indicating whether or not to set the addressvalue is provided in the memory 19, and the memory-state saving programgenerator 23 f generates the memory-state saving program for saving thestate of the memory 19 before the compaction. Then, the compactionprogram generator 23 b generates the compaction program for compactingthe memory 19. Further, after the memory 19 is compacted, the relocatingprogram generator 23 g generates the relocating program for relocatingthe address value for the entry having the address value set based onthe identifier by referring to the saved state of the memory 19 beforethe compaction. Accordingly, the fragmentation of the memory can besolved, enabling the effective use of the memory.

Next, a third modification of the method for solving the fragmentationof the memory is described. In the third modification, an area in amemory is divided into an address-value memory area where address valuesare saved and a non-address-value memory area where values other thanthe address values such as numerical values are saved, and the addressvalues are relocated only for the address-value memory area after thecompaction.

FIG. 24 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving the fragmentation according to the thirdmodification. It should be noted that no description is given on thesame elements as those of the other embodiments by identifying them bythe same reference numerals.

As shown in FIG. 24, a server 11 is provided with a communicator 22 anda compiling unit 14. The compiling unit 14 is provided with a programexecuting unit 16 and a program storage 17. The program executing unit16 includes a memory-state saving program generator 23 h, a compactionprogram generator 23 b and an address-value memory relocating programgenerator 23 i.

The memory-state saving program generator 23 h generates a memory-statesaving program for saving states of an address-value memory area whereaddress values are saved and a non-address-value memory area wherevalues other than the address values are saved.

The address-value memory relocating program generator 23 i generates arelocating program for relocating the address values of only theaddress-value memory area by referring to the saved state of theaddress-value memory area before the compaction after the address-valuememory area and non-address-value memory area are compacted.

The terminal unit 12 is provided with a program executing unit 18, amemory 19 and a communicator 21. The program executing unit 18 includesa memory-state saving device 24 h, a compacting device 24 b, and anaddress-value memory relocating device 24 i.

The memory 19 is divided into an address-value memory area where addressvalues are saved and a non-address-value memory area where values otherthan the address values such as numerical values are saved.

The memory-state saving device 24 h saves the states of theaddress-value memory area where the address values are saved and thenon-address-value memory area where values other than the address valuessuch as numerical values are saved before the compaction.

The address-value memory relocating device 24 i relocates the addressvalues of only the address-value memory area by referring to the stateof the address-value memory area before the compaction saved by thememory-state saving device 24 h after the address-value memory area andnon-address-value memory area are compacted.

FIGS. 25A, 25B and 25C are diagrams showing the method for solving thefragmentation according to the third modification, wherein FIG. 25Ashows a fragmented state of a memory before the compaction, FIG. 25Bshows a state of the memory after the compaction, and FIG. 25C shows astate of the memory after the relocation.

As shown in FIG. 25A, the memory 19 is divided into the address-valuememory area where the address values are saved and the non-address-valuememory area where values other than the address values such as numericalvalues are saved.

In the address-value memory area of the memory 19 shown in FIG. 23A, anarea 0x100 to 0x200 is unused; 0x304 which is an address value is savedat 0x300; 0x200 is saved at 0x304; an area from 0x500 and above isunused, and other data are saved in other areas. Further, in thenon-address-value memory area of the memory 19; an area from 0x5000 to0x5100 is unused; a value of 1000 is saved at 0x5200; a value of 2000 issaved at 0x5204; an area from 0x5400 and above is unused; and other dataare saved in other areas.

When the memory 19 of the state shown in FIG. 25A is compacted, thestate shown in FIG. 25B is attained. Specifically, as shown in FIG. 25B,the unused area from 0x100 to 0x200 disappears, an area from 0x100 to0x400 is integrated, and an area from 0x400 and above is an unused areain the address-value memory area of the memory 19. Further, in thenon-address-value memory area of the memory 19, the unused area from0x5000 to 0x5100 disappears; an area 0x5000 to 0x5300 is integrated; andan area from 0x5300 and above is unused.

In this case, since the addresses in memory 19 are shifted, the address0x300 where the address value 0x304 was saved before the compaction isshifted to 0x200; the address 0x304 where the address value 0x200 wassaved before the compaction is shifted to 0x204; and the address 0x200pointed by the address 0x304 is shifted to 0x100. As a result, theaddresses pointed by the pointer variables saved at the addresses 0x200and 0x240 disappear as shown in FIG. 25B.

Accordingly, the memory-state saving device 24 h saves the states of theaddress-value memory area and non-address-value memory area of thememory 19 before the compaction, and the address-value relocating device24 i relocates the address values of only the address-value memory areaby referring to the state of the address-value memory area before thecompaction saved by the memory-state saving device 24 h and the state ofthe address-value memory area of the memory 19 after the compactionafter the memory 19 is compacted. For example, as shown in FIG. 25C, theaddress-value memory relocating device 24 i relocates the address valuesaved at the address 0x200 from 0x304 to 0x204 which is a correctaddress value and the address value saved at the address 0x204 from0x200 to 0x100 which is a correct address value.

In this way, the address-value memory area for saving the address valuesand the non-address-value memory for saving the values other than theaddress values are provided, and the memory-state saving programgenerator 23 h generates the memory-state saving program for saving thestates of the address-value memory area and the non-address-value memoryarea before the compaction. The compaction program generator 23 bgenerates the compaction program for compacting the address-value memoryarea and the non-address-value memory area. After the address-valuememory area and the non-address-value memory area are compacted, theaddress-value memory relocating program generator 23 i generates theaddress-value memory relocating program for relocating the addressvalues of only the address-value memory area by referring to the savedstate of the address-value memory area before the compaction.Accordingly, the fragmentation of the memory can be solved, enabling theeffective use of the memory.

Next, a fourth modification of the method for solving the fragmentationof the memory is described. In the fourth modification, an area in amemory is divided into an address-value memory area where address valuesare saved and a non-address-value memory area where values other thanthe address values such as numerical values are saved; n identificationnumber for identifying a module and an identification flag (identifier)for discriminating whether to set an address of a data area of themodule or to set an address of a code area for a pointer variable in thememory are provided; the identification number and the identificationflag are set upon substituting the address for the pointer variable atthe time of executing the module; and the address is recalculated basedon the identification number and the identification flag only for theaddress-value memory area after the compaction.

FIG. 26 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving the fragmentation according to thefourth modification. It should be noted that no description is given onthe same elements as those of the other embodiments by identifying themby the same reference numerals.

As shown in FIG. 26, a server 11 is provided with a communicator 22 anda compiling unit 14. The compiling unit 14 is provided with a programexecuting unit 16 and a program storage 17. The program executing unit16 includes an identification number/identification flag setting programgenerator 23 j, a compaction program generator 23 b and a recalculatingprogram generator 23 k.

The identification number/identification flag setting program generator23 j generates a setting program for setting an identification numberfor identifying a program module and an identification flag fordiscriminating whether to set an address of a data area of the programmodule or to set an address of a code area upon substituting an addressvalue for a pointer at the time of executing the program module.

The recalculating program generator 23 k generates a recalculatingprogram for recalculating the address value based on the identificationnumber and the identifier after the memory 19 is compacted.

The terminal unit 12 is provided with a program executing unit 18, amemory 19 and a communicator 21. The program executing unit 18 includesan identification number/identification flag setting device 24 j, acompacting device 24 b, and a recalculating device 24 k.

The memory 19 is divided into an address-value memory area where addressvalues are saved and a non-address-value memory area where values otherthan the address values such as numerical values are saved. The memory19 is also provided with an area for saving the identification numberfor identifying the program module and an identification flag fordiscriminating whether to set the address of the data area of theprogram module or to set the address of the code area.

The identification number/identification flag setting device 24 j setsthe identification number for identifying the program module and theidentification flag for discriminating whether to set the address of thedata area of the program module or to set the address of the code areaupon substituting the address value for the pointer at the time ofexecuting the program module.

The recalculating device 24 k recalculates the address value based onthe identification number and the identifier after the memory 19 iscompacted.

First, in this modification, upon saving the program module in thememory, the identification number for identifying the program module isdesignated and a table relating this identification number to theleading addresses of the data area and the code area of the programmodule is saved beforehand. Then, the identificationnumber/identification flag setting device 24 j sets the identificationnumber for identifying the program module and the identification flagfor discriminating whether to set the address of the data area of theprogram module or to set the address of the code area upon substitutingthe address value for the pointer at the time of executing the programmodule. The identification flag is set to “1” in the case of setting theaddress of the data area of the program module for the pointer whilebeing set to “0” in the case of setting the address of the code area ofthe program module for the pointer. Then, the compacting device 24 bcompacts the memory 19.

After the memory 19 is compacted, the recalculating device 24 krecalculates the address value based on the identification number andthe identifier by referring to the table saved beforehand, and sets therecalculated address value as a new address value.

Although the memory 19 is divided into the address-value memory areawhere the address values are saved and the non-address-value memory areawhere the values other than the address values such as numerical valuesare saved in this modification, the present invention is notparticularly limited thereto. Information indicating the location of theaddress value may be latched.

In this way, the identification number for identifying the module andthe identification flag for discriminating whether to set the address ofthe data area of the module or to set the address of the code area areprovided in the memory 19, and the identification number/identificationflag setting program generator 23 j generates the setting program forsetting the identification number and the identification flag uponsubstituting the address value for the pointer. The compaction programgenerator 23 b generates the compaction program for compacting thememory 19. After the memory 19 is compacted, the recalculating programgenerator 23 k generates the recalculating program for recalculating theaddress value based on the identification number and the identificationflag. Accordingly, the fragmentation of the memory can be solved,enabling the effective use of the memory.

Next, a fifth modification of the method for solving the fragmentationis described. In the fifth modification, an area in a memory is dividedinto an address-value memory area where address values are saved and anon-address-value memory area where values other than the address valuessuch as numerical values are saved; identification number foridentifying a module and an identification flag (identifier) fordiscriminating whether to set an address of a data area of the module orto set an address of a code area for a pointer variable in the memory isprovided; the identification number and the identification flag are setupon substituting the address for the pointer variable at the time ofexecuting the module and an offset value from the leading address of thedata area or an offset value from the leading address of the code areais set as the address value. Upon using the pointer variable at the timeof executing the program module, an actual address converted by addingthe offset value to the leading address of the data area or the leadingaddress of the code area is used.

Since the fifth and fourth modifications differ only in that the addressvalue is saved as the offset value, no further description is given.

In this way, the identification number for identifying the module andthe identification flag for discriminating whether to set the address ofthe data area of the module or to set the address of the code area areprovided in the memory 19, and an offset-value setting program forsetting the identification number and the identification flag uponsubstituting the address value for the pointer and setting the offsetvalue from the leading address of the data area or from the leadingaddress of the code area is generated. Then, an actual addressconverting program for converting the address value into the actualaddress by adding the leading address of the data area or the leadingaddress of the code area to the offset value upon using the pointer isgenerated. Accordingly, the fragmentation of the memory can be solved,enabling the effective use of the memory.

Next, a sixth modification of the method for solving the fragmentationis described. In the sixth modification, a reference is provided withhandles for indirectly referring to objects; whether or not there is anyhandle indicating a code area or a data area shifted by the compactionis searched; and if the handle indicating the code area or the data areais found, this handle is relocated and the code area or the data area iscompacted after all the handles are relocated.

FIG. 27 is a block diagram showing the constructions of a compiling unitand a terminal unit for solving the fragmentation according to the sixthmodification. It should be noted that no description is given on thesame elements as those of the other embodiments by identifying them bythe same reference numerals.

As shown in FIG. 27, a server 11 is provided with a communicator 22 anda compiling unit 14. The compiling unit 14 is provided with a programexecuting unit 16 and a program storage 17. The program executing unit16 includes a handle searching program generator 23 l, a compactionprogram generator 23 b and a handle relocating program generator 23 m.

The handle searching program generator 23 l generates a searchingprogram for searching whether or not there is any handle indicating acode area or a data area of a program shifted by the compaction.

The compaction program generator 23 b generates a compaction program forapplying the compaction for each code area or each data area of theprogram module.

The handle relocating program generator 23 m generates a handlerelocating program for relocating the handle if the handle indicatingthe code area or the data area was found.

The compaction program generator 23 b also generates a compactionprogram for compacting the code area or the data area after all thehandles are relocated.

The terminal unit 12 is provided with a program executing unit 18, amemory 19 and a communicator 21. The program executing unit 18 includesa handle searching device 24 l, a compacting device 24 b, and a handlerelocating device 24 m.

An area for the handles used by the reference to indirectly refer to theaddress of an object is provided in the memory 19. Accordingly, thereference indirectly refers to the object via the handle instead ofdirectly referring to the object. The handles and the objects have anone-to-one correspondence. This means no existence of a plurality ofhandles indicating the same object. Further, the references and theobjects have a many-to-one correspondence because the objects have apossibility of being referred to by a plurality of different references.

The handle searching device 24 l searches whether or not there is anyhandle indicating the code area or the data area of the program moduleshifted by the compaction. The compacting device 24 b applies thecompaction to each code area or each data area of the program module.The handle relocating device 24 m relocates an address value of thehandle in the case of finding the handle indicating the code area or thedata area. The compacting device 24 b compacts the code area or the dataarea after all the handles are relocated.

In this way, the handle searching program generator 23 l generates thesearching program for searching whether or not there is any handleindicating the code area or the data area shifted by the compaction. Ifthe handle indicating the code area or the data area is found, thehandle relocating program generator 23 m generates the handle relocatingprogram for relocating the handle. After all the handles are relocated,the compaction program generator 23 b generates the compaction programfor compacting the code area or the data area. Accordingly, thefragmentation of the memory can be solved, enabling the effective use ofthe memory.

The source program, the object program and all the other programsdescribed above are saved in a computer-readable storage medium and usedand executed upon being read from the computer and are caused tocommunicate with other computers via a network such as Internet in somecases. Similarly, a compiler program to execute the above translation isalso saved in the computer-readable storage medium and executes acompiling (translation/conversion from the source program to the objectprogram) by being read from the computer and is caused to communicatewith the other computers via a network such as Internet.

By this compiler program, the computer executes a compiling methodspecified by this compiler program. This computer hardware and thecompiler program construct the compiling unit as a whole.

Summary of the Embodiments

Various embodiments of the present invention described above can besummarized as follows.

Specifically, the complier program according to the present invention isfor converting the source program into the object program and causes thecomputer to function as the address saving program generating means forsaving the address saving program for saving the data memory areaaddress used by the calling program module included in the sourceprogram; the address setting program generating means for generating theaddress setting program for setting the data memory area address used bythe other program module to be called by the calling program module; thetransferring program generating means for generating the transferringprogram for the transfer from the first subprogram included in thecalling program module to the second subprogram included in the otherprogram module; the address resetting program generating means forgenerating the address resetting program for reading and resetting thesaved data memory area address for the calling program module after thereturn from the second subprogram as a transfer end to the firstsubprogram; and the accessing program generating means for generatingthe accessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein.

With this configuration, the address saving program generating meansgenerates the address saving program for saving the data memory areaaddress used by the calling program module included in the sourceprogram. The address setting program generating means generates theaddress setting program for setting the data memory area address used bythe other program module to be called by the calling program module.Further, the transferring program generating means generates thetransferring program for the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module. The address resetting program generating meansgenerates the address resetting program for reading and resetting thesaved data memory area address for the calling program module after thereturn from the second subprogram as the transfer end to the firstsubprogram. The accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Particularly, a reentrant object program which can conform to thepurpose of storing an object program in a limited memory area such as aso-called device installation program and storing an object program foran advanced and highly functional information processing in a limitedmemory like mobile information processings of recent years can beautomatically generated. Thus, dynamic links between the modules can berealized.

In the above compiler program, it is preferred that the computer iscaused to further function as the discriminating means fordiscriminating whether or not to shorten the process based on thedescription of the other program module including the second subprogramcalled by the first subprogram included in the calling program moduleincluded in the source program; if the discriminating meansdiscriminates the process not to be shortened, the address savingprogram generating means generates the address saving program for savingthe data memory area address used by the calling program module, theaddress setting program generating means generates the address settingprogram for setting the data memory area address used by the otherprogram module called by the calling program module, the transferringprogram generating means generates the transferring program for thetransfer from the first subprogram included in the calling programmodule to the second subprogram included in the other program module,the address resetting program generating means generates the addressresetting program for reading and resetting the saved data memory areaaddress for the calling program module after the return from the secondsubprogram as the transfer end to the first subprogram, and theaccessing program generating means generates the accessing program foraccessing the data memory area for the other program module using therelative address from the set data memory area address for the otherprogram module when the other program module accesses the data memoryarea therefor included therein; and if the discriminating meansdiscriminates the process to be shortened, the transferring programgenerating means generates the transferring program for the transferfrom the first subprogram included in the calling program module to thesecond subprogram included in the other program module and the accessingprogram generating means generates the accessing program for accessingthe data memory area for the other program module using the relativeaddress from the data memory area address for the calling program modulewhen the other program module accesses the data memory area thereforincluded therein.

With this configuration, whether or not to shorten the process isdiscriminated based on the description of the other program moduleincluding the second subprogram called from the first subprogramincluded in the calling program module included in the source program.If the discriminating means discriminates the process not to beshortened, the address saving program generating means generates theaddress saving program for saving the data memory area address used bythe calling program module. Then, the address setting program generatingmeans generates the address setting program for setting the data memoryarea address used by the other program module called by the callingprogram module. Further, the transferring program generating meansgenerates the transferring program for the transfer from the firstsubprogram included in the calling program module to the secondsubprogram included in the other program module, and the addressresetting program generating means generates the address resettingprogram for reading and resetting the saved data memory area address forthe calling program module after the return from the second subprogramas the transfer end to the first subprogram. Furthermore, the accessingprogram generating means generates the accessing program for accessingthe data memory area for the other program module using the relativeaddress from the set data memory area address for the other programmodule when the other program module accesses the data memory areatherefor included therein.

On the other hand, if the discriminating means discriminates the processto be shortened, the transferring program generating means generates thetransferring program for the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module. Then, the accessing program generating meansgenerates the accessing program for accessing the data memory area forthe other program module using the relative address from the data memoryarea address for the calling program module when the other programmodule accesses the data memory area therefor included therein.

Since whether or not to shorten the process is discriminated based onthe description of the other program module including the secondsubprogram called from the first subprogram included in the callingprogram module included in the source program, the processings ofsaving, setting and resetting the address can be deleted to speed up theexecution of the object program and the size of the object program canbe made smaller by performing no unnecessary processing in cases wherethe calling program module and the called-side program module need notnecessarily use different data areas.

In the above compiler program, it is preferable that, after the secondsubprogram included in the other program module is called from the firstsubprogram included in the calling program module included in the sourceprogram, the address setting program generating means generates theaddress setting program for reading and setting the data memory areaaddress for the other program module from the data memory area addresstables for the respective program modules saved in the executing unitsof the calling program module, and the accessing program generatingmeans generates the accessing program for accessing the other programmodule for the other program module using the relative address from theset data memory area address for the other program module when the otherprogram module accesses the data memory area therefor included therein.

With this configuration, after the second subprogram included in theother program module is called from the first subprogram included in thecalling program module included in the source program, the addresssetting program generating means generates the address setting programfor reading and setting the data memory area address for the otherprogram module from the data memory area address tables for therespective program modules saved in the executing units of the callingprogram module. Then, the accessing program generating means generatesthe accessing program for accessing the other program module for theother program module using the relative address from the set data memoryarea address for the other program module when the other program moduleaccesses the data memory area therefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, accesses to, for example, the external variables do notcollide since they are made via the data memory area address tables forthe respective program modules. Thus, the program module can beconfigured to be reentrant.

In the above compiler program, it is preferable that the computer iscaused to further function as the discriminating means fordiscriminating whether or not to shorten the process based on thedescription of the other program module including the second subprogramcalled from the first subprogram included in the calling program moduleincluded in the source program; if the discriminating meansdiscriminates the process not to be shortened, after the secondsubprogram included in the other program module is called from the firstsubprogram included in the calling program module included in the sourceprogram, the address setting program generating means generates theaddress setting program for setting and reading the data memory areaaddress for the other program module from the data memory area addresstables for the respective program modules saved in the executing unitsof the calling program module, and the accessing program generatingmeans generates the accessing program for accessing the data memory areafor the other program module using the relative address from the setdata memory area address for the other program module when the otherprogram module accesses the data memory area therefor included therein;and if the discriminating means discriminates the process to beshortened, the accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the data memory areaaddress for the calling program module when the other program moduleaccesses the data memory area therefor included therein.

With this configuration, the discriminating means discriminates whetheror not to shorten the process based on the description of the otherprogram module including the second subprogram to be called from thefirst subprogram included in the calling program module included in thesource program. If the discriminating means discriminates the processnot to be shortened, after the second subprogram included in the otherprogram module is called from the first subprogram included in thecallings-de program module included in the source program, the addresssetting program generating means generates the address setting programfor setting and reading the data memory area address for the otherprogram module from the data memory area address tables for therespective program modules saved in the executing units of the callingprogram module. Then, the accessing program generating means generatesthe accessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein.

On the other hand, if the discriminating means discriminates the processto be shortened, the accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the data memory areaaddress for the calling program module when the other program moduleaccesses the data memory area therefor included therein.

Since whether or not to shorten the process is discriminated based onthe description of the other program module including the secondsubprogram called from the first subprogram included in the callingprogram module, the processing of setting the address via the datamemory area address tables for the respective program modules can bedeleted to speed up the execution of the object program and the size ofthe object program can be made Smaller by performing no unnecessaryprocessing in cases where the calling program module and the called-sideprogram module need not necessarily use different data areas.

Further, in the above compiler program, the description of the otherprogram module including the second subprogram to be called from thefirst subprogram included in the calling program module included in thesource program is preferably a declaration described for each secondsubprogram.

With this configuration, the processing of setting the address can bedeleted based on the presence or absence of this declaration accordingto the processing content of the second subprogram, thereby speeding upthe execution of the object program, since the description of the otherprogram module including the second subprogram called from the firstsubprogram included in the calling program module included in the sourceprogram is a declaration described for each second subprogram.

Further, in the above compiler program, the source program including theother program module including the second subprogram called by thecalling program module preferably includes a description for specifyingwhich of the execution common data memory area for the other programmodule the external variables included in the other program modulecommonly access upon a plurality of executions of the calling programmodule and the execution intrinsic data memory areas for the otherprogram module they commonly access every time the calling programmodule is executed is to be used.

With this configuration, which of the execution common data memory areafor the other program module the external variables included in theother program module commonly access upon a plurality of executions ofthe calling program module and the execution intrinsic data memory areasfor the other program module they commonly access every time the callingprogram module is executed is to be used is specified by the descriptionincluded in the source program including the other program moduleincluding the second subprogram called by the calling program module.

Accordingly, even if the other program module is called from a pluralityof calling program modules, accesses are made to the execution intrinsicdata memory areas provided for the respective calling program modules.Thus, no collision occurs in accesses to, for example, the externalvariables and the program module can be configured to be reentrant.Further, even if the other program module is called from a plurality ofcalling program modules, accesses are made to the execution common datamemory area shared by the respective calling program modules. Thus, forexample, some of the external variables can be commonly used.

Further, in the above compiler program, the description for specifyingwhich of the execution common data memory area for the other programmodule and the execution intrinsic data memory area for the otherprogram module is to be used is preferably a declaration described foreach external variable included in the other program module.

With this configuration, since the description for specifying which ofthe execution common data memory area for the other program module andthe execution intrinsic data memory area for the other program module isto be used is the declaration described for each external variableincluded in the other program module, the execution common data memoryarea and the execution intrinsic data memory area can be easily properlyused by judging the presence or absence of this declaration.

In the above complier program, it is preferable that the address savingprogram generating means generates the address saving program for savingthe execution common data memory area address and the executionintrinsic data memory area address for the calling program module; theaddress setting program generating means sets the execution common datamemory area address and the execution intrinsic data memory area addressfor the other program module to be called by the calling program module;the transferring program generating means generates the transferringprogram for the transfer from the first subprogram to the secondsubprogram; the address resetting program generating means generates theaddress resetting program for reading and resetting the saved executionintrinsic data memory area address and execution common data memory areaaddress for the calling program module after the return from the secondsubprogram as the transfer end to the first subprogram; and theaccessing program generating means generates the accessing program foraccessing the data memory area for the other program module using therelative address from the set execution intrinsic data memory areaaddress for the other program module when the other program moduleaccesses the execution intrinsic data memory area therefor includedtherein and accessing the data memory area using the relative addressfrom the set execution common data memory area address for the otherprogram module when the other program module accesses the executioncommon data memory area therefor included therein.

With this configuration, the address saving program generating meansgenerates the address saving program for saving the execution commondata memory area address and the execution intrinsic data memory areaaddress for the calling program module. The address setting programgenerating means sets the execution common data memory area address andthe execution intrinsic data memory area address for the other programmodule to be called by the calling program module. The transferringprogram generating means generates the transferring program for thetransfer from the first subprogram to the second subprogram. The addressresetting program generating means generates the address resettingprogram for reading and resetting the saved execution intrinsic datamemory area address and execution common data memory area address forthe calling program module after the return from the second subprogramas the transfer end to the first subprogram. The accessing programgenerating means generates the accessing program for accessing the datamemory area using the relative address from the set execution intrinsicdata memory area address for the other program module when the otherprogram module accesses the execution intrinsic data memory areatherefor included therein and accessing the data memory area using therelative address from the set execution common data memory area addressfor the other program module when the other program module accesses theexecution common data memory area therefor included therein.

Accordingly, the execution intrinsic data memory area and the executioncommon data memory area can be properly used. Even if the other programmodule is called by a plurality of calling program modules, accesses to,for example, an external variable do not collide, whereby the programmodule can be configured to be reentrant and a plurality of programmodules can share the external variable.

In the above compiler program, it is preferable that, after the otherprogram module is called from the calling program module included in thesource program, the address setting program generating means generatesthe address setting program for reading and setting the executionintrinsic data memory area address for the other program module from thedata memory area address tables for the respective program modules savedin the execution units of the calling program module and reading andsetting the execution common data memory area address for the otherprogram commonly accessed by a plurality of executions of the callingprogram module; and the accessing program generating means generates theaccessing program for accessing the data memory area using the relativeaddress from the set execution intrinsic data memory area address forthe other program when the other program module accesses the executionintrinsic data memory area therefor included therein and accessing thedata memory area using the relative address from the set executioncommon data memory area address for the other program module when theother program module accesses the execution common data memory areatherefor included therein.

With this configuration, after the other program module is called fromthe calling program module included in the source program, the addresssetting program generating means generates the address setting programfor reading and setting the execution intrinsic data memory area addressfor the other program module from the data memory area address tablesfor the respective program modules saved in the execution units of thecalling program module and reading and setting the execution common datamemory area address for the other program commonly accessed by aplurality of executions of the calling program module. The accessingprogram generating means generates the accessing program for accessingthe data memory area using the relative address from the set executionintrinsic data memory area address for the other program when the otherprogram module accesses the execution intrinsic data memory areatherefor included therein and accessing the data memory area using therelative address from the set execution common data memory area addressfor the other program module when the other program module accesses theexecution common data memory area therefor included therein.

Accordingly, the execution intrinsic data memory area and the executioncommon data memory area can be properly used. Even if the other programmodule is called by a plurality of calling program modules, accesses to,for example, an external variable do not collide, whereby the programmodule can be configured to be reentrant and a plurality of programmodules can share the external variable.

Further, in the above compiler program, the address saving programgenerating means preferably generates the address saving program forsaving the execution common data memory area address and the executionintrinsic data memory area address for the calling program module in thestack memory prior to the data necessary for the transfer from the firstsubprogram to the second subprogram.

With this configuration, the address saving program generating meansgenerates the address saving program for saving the execution commondata memory area address and the execution intrinsic data memory areaaddress for the calling program module in the stack memory prior to thedata necessary for the transfer from the first subprogram to the secondsubprogram.

Accordingly, the other program module to be called by the callingprogram module can be exempted from the need to concern the presence orabsence of the execution common data memory area address and executionintrinsic data memory area address saved in the stack memory.

Further, in the above compiler program, the calling program moduleincluded in the source program and the other program module includingthe second subprogram to be called from the first subprogram included inthe calling program module are preferably the same program module.

With this configuration, the calling program module included in thesource program and the other program module including the secondsubprogram to be called from the first subprogram included in thecalling program module are the same program module.

Accordingly, the process inside the module can be completed withoutreducing its processing speed by shortening the call within the samemodule.

Further, in the above compiler program, it is preferable that thecalling program module includes the code area and the data area; theother program module includes the code area and the data area; and thecomputer is caused to further function as the identification-numberobtaining program generating means for generating theidentification-number obtaining program for obtaining the identificationnumber for identifying the other program module upon the receipt of thecall command to the other program from the calling program module; theleading-address obtaining program generating means for generating theleading-address obtaining program for obtaining the leading address ofthe data area of the other program module from the table relating theidentification number of the calling program module to the leadingaddress of the data area of the calling program module and relating theidentification number of the other program module to the leading addressof the data area of the other program module, using the obtainedidentification number as an index; and the leading-address switchingprogram generating means for generating the leading-address switchingprogram for switching the obtained leading address of the data area ofthe other program module and the leading address of the data area of thecalling program module.

With this configuration, the calling program module includes the codearea and the data area, and the other program module includes the codearea and the data area. The identification-number obtaining programgenerating means generates the identification-number obtaining programfor obtaining the identification number for identifying the otherprogram module upon the receipt of the call command to the other programfrom the calling program module. The leading-address obtaining programgenerating means generates the leading-address obtaining program forobtaining the leading address of the data area of the other programmodule from the table relating the identification number of the callingprogram module to the leading address of the data area of the callingprogram module and relating the identification number of the otherprogram module to the leading address of the data area of the otherprogram module, using the obtained identification number as an index.The leading-address switching program generating means generates theleading-address switching program for switching the obtained leadingaddress of the data area of the other program module and the leadingaddress of the data area of the calling program module.

Accordingly, the amount of the data of the table can be reduced and thetable can conform to small-size apparatuses having a strict resourcerestriction by preparing the table for the address conversion not pageby page, but module by module.

In the above compiler program, it is preferable that the calling programmodule includes the code area and the data area; the other programmodule includes the code area and the data area; and the computer iscaused to further function as the identification-number designatingprogram generating means for generating the identification-numberdesignating program for designating the identification number foridentifying the calling program module and the one for identifying theother program module; the table preparing program generating means forgenerating the table preparing program for preparing the table relatingthe designated identification number of the calling program module tothe leading address of the data area of the calling program module andrelating the designated identification number of the other programmodule to the leading address of the data area of the other programmodule; the identification-number obtaining program generating means forgenerating the identification-number obtaining program for obtaining theidentification number of the other program module upon the receipt ofthe call command to the other program from the calling program module;the leading-address obtaining program generating means for generatingthe leading-address obtaining program for obtaining the leading addressof the data area of the other program module from the prepared tableusing the obtained identification number as an index; and theleading-address switching program generating means for generating theleading-address switching program for switching the obtained leadingaddress of the data area of the other program module and the leadingaddress of the data area of the calling program module.

With this configuration, the calling program module includes the codearea and the data area, and the other program module includes the codearea and the data area. The identification-number designating programgenerating means generates the identification-number designating programfor designating the identification number for identifying the callingprogram module and the one for identifying the other program module. Thetable preparing program generating means generates the table preparingprogram for preparing the table relating the designated identificationnumber of the calling program module to the leading address of the dataarea of the calling program module and relating the designatedidentification number of the other program module to the leading addressof the data area of the other program module. The identification-numberobtaining program generating means generates the identification-numberobtaining program for obtaining the identification number of the otherprogram module upon the receipt of the call command to the other programfrom the calling program module. The leading-address obtaining programgenerating means generates the leading-address obtaining program forobtaining the leading address of the data area of the other programmodule from the prepared table using the obtained identification numberas an index. The leading-address switching program generating meansgenerates the leading-address switching program for switching theobtained leading-address of the data area of the other program moduleand the leading address of the data area of the calling program module.

Accordingly, the amount of the data of the table can be reduced and thetable can conform to small-size apparatuses having a strict resourcerestriction by preparing the table for the address conversion not pageby page, but module by module.

In the above compiler program, it is preferable that the computer iscaused to further function as the address latching program generatingmeans for generating the address latching program for latching theaddress to the variable or function defined outside the other programmodule; and the accessing program generating means generates theaccessing program for accessing the variable defined inside the otherprogram module using the relative address from the obtained leadingaddress and accessing the function defined inside the other programmodule using the relative address from the program counter whileindirectly accessing the variable or function defined outside the otherprogram module via the latched address after accessing the latchedaddress using the relative address from the obtained leading address.

With this configuration, the address latching program generating meansgenerates the address latching program for latching the address to thevariable or function defined outside the other program module. Theaccessing program generating means generates the accessing program foraccessing the variable defined inside the other program module using therelative address from the obtained leading address and accessing thefunction defined inside the other program module using the relativeaddress from the program counter while indirectly accessing the variableor function defined outside the other program module via the latchedaddress after accessing the latched address using the relative addressfrom the obtained leading address. Accordingly, the variable or functiondefined outside the other program module can be indirectly accessed viathe latched address.

In the above compiler program, it is preferable to cause the computer tofurther function as the ending program generating means for generatingthe ending program for ending the application comprised of at least onemodule and being presently executed; the compaction program generatingmeans for generating the compaction program for compacting the memoryafter the application is ended; and the resuming program generatingmeans for generating the resuming program for resuming the applicationfrom the beginning after the memory is compacted.

With this configuration, the ending program generating means generatesthe ending program for ending the application comprised of at least onemodule and being presently executed. After the application is ended, thecompaction program generating means generates the compaction program forcompacting the memory. After the memory is compacted, the resumingprogram generating means generates the resuming program for resuming theapplication from the beginning. Accordingly, the fragmentation of thememory can be solved, thereby enabling the effective use of the memory.

In the above compiler program, it is preferable to cause the computer tofurther function as the ending program generating means for generatingthe ending program for ending the application comprised of at least onemodule and being presently executed; the saving program generating meansfor generating the saving program for saving the information independentof the address values of the application until the application wasended; the compaction program generating means for generating thecompaction program for compacting the memory; and the executing programgenerating means for generating the executing program for reading thesaved information and executing the application based on the readinformation up to the state where the application was ended after thememory was compacted.

With this configuration, the ending program generating means generatesthe ending program for ending the application comprised of at least onemodule and being presently executed. The saving program generating meansgenerates the saving program for saving the information independent ofthe address values of the application until the application was ended.The compaction program generating means generates the compaction programfor compacting the memory. After the memory is compacted, the executingprogram generating means generates the executing program for reading thesaved information and executing the application based on the readinformation up to the state where the application was ended.Accordingly, the fragmentation of the memory can be solved, therebyenabling the effective use of the memory.

In the above compiler program, it is preferable that the identifierindicating whether or not to set the address value is provided in thememory and the computer is caused to further function as thememory-state saving program generating means for generating thememory-state saving program for saving the state of the memory beforethe compaction; the compaction program generating means for generatingthe compaction program for compacting the memory; and the relocatingprogram generating means for generating the relocating program forrelocating the address value based on the identifier for an entry havingthe address value set by referring to the saved state of the memorybefore the compaction.

With this configuration, the identifier indicating whether or not to setthe address value is provided in the memory, and the memory-state savingprogram generating means generates the memory-state saving program forsaving the state of the memory before the compaction. The compactionprogram generating means generates the compaction program for compactingthe memory. Further, after the memory is compacted, the relocatingprogram generating means generates the relocating program for relocatingthe address value based on the identifier for an entry having theaddress value set by referring to the saved state of the memory beforethe compaction. Accordingly, the fragmentation of the memory can besolved, thereby enabling the effective use of the memory.

In the above compiler program, it is preferable that the address-valuememory for saving the address values and the non-address-value memoryfor saving values other than the address values are provided and thecomputer is caused to further function as the memory-state savingprogram generating means for generating the memory-state saving programfor saving the states of the address-value memory and thenon-address-value memory before the compaction; the compaction programgenerating means for generating the compaction program for compactingthe address-value memory and the non-address-value memory; and therelocating program generating means for generating the relocatingprogram for relocating the address values of only the address-valuememory by referring to the saved states of the address-value memory andthe non-address-value memory before the compaction after theaddress-value memory and the non-address-value memory are compacted.

With this configuration, the address-value memory for saving the addressvalues and the non-address-value memory for saving values other than theaddress values are provided, and the memory-state saving programgenerating means generates the memory-state saving program for savingthe states of the address-value memory and the non-address-value memorybefore the compaction. The compaction program generating means generatesthe compaction program for compacting the address-value memory and thenon-address-value memory. After the address-value memory and thenon-address-value memory are compacted, the relocating programgenerating means generates the relocating program for relocating theaddress values of only the address-value memory by referring to thesaved states of the address-value memory and the non-address-valuememory before the compaction. Accordingly, the fragmentation of thememory can be solved, thereby enabling the effective use of the memory.

In the above compiler program, it is preferable that the identificationnumber for identifying the module and the identifier for identifyingwhether to set the address of the data area of the module or to set theaddress of the code area are provided in the memory, and the computer iscaused to further function as the setting program generating means forgenerating the setting program for setting the identification number andthe identifier upon substituting the address value for the pointer; thecompaction program generating means for generating the compactionprogram for compacting the memory; and the recalculating programgenerating means for generating the recalculating program forrecalculating the address value based on the identification number andthe identifier after the memory is compacted.

With this configuration, the identification number for identifying themodule and the identifier for identifying whether to set the address ofthe data area of the module or to set the address of the code area areprovided in the memory, and the setting program generating meansgenerates the setting program for setting the identification number andthe identifier upon substituting the address value for the pointer. Thecompaction program generating means generates the compaction program forcompacting the memory. After the memory is compacted, the recalculatingprogram generating means generates the recalculating program forrecalculating the address value based on the identification number andthe identifier. Accordingly, the fragmentation of the memory can besolved, thereby enabling the effective use of the memory.

Further, in the above compiler program, it is preferable that theidentification number for identifying the module and the identifier foridentifying whether to set the address of the data area of the module orto set the address of the code area are provided in the memory, and thecomputer is caused to further function as the offset-value settingprogram generating means for generating the offset-value setting programfor setting the identification number and the identifier uponsubstituting the address value for the pointer and setting the offsetvalue from the leading address of the data area or that of the codearea; and the actual-address converting program generating means forgenerating the actual-address converting program for the conversion intothe actual address by adding the leading address of the data area orthat of the code area to the offset value upon using the pointer.

With this configuration, the identification number for identifying themodule and the identifier for identifying whether to set the address ofthe data area of the module or to set the address of the code area areprovided in the memory, and the offset-value setting program generatingmeans generates the offset-value setting program for setting theidentification number and the identifier upon substituting the addressvalue for the pointer and setting the offset value from the leadingaddress of the data area or that of the code area. Upon using thepointer, the actual-address converting program generating meansgenerates the actual-address converting program for the conversion intothe actual address by adding the leading address of the data area orthat of the code area to the offset value. Accordingly, thefragmentation of the memory can be solved, thereby enabling theeffective use of the memory.

In the above compiler program, it is preferable that the computer iscaused to further function as the compaction program generating meansfor generating the compaction program for compacting each code area oreach data area of the module, the searching program generating means forgenerating the searching program for searching whether or not there isany handle indicating the code area or the data area to be shifted bythe compaction, and the handle relocating program generating means forgenerating the handle relocating program for relocating the handle ifthe handle indicating the code area or the data area is found, and thecompaction program generating means generates the compaction program forcompacting the code area or the data area after all the handles arerelocated.

With this configuration, the searching program generating meansgenerates the searching program for searching whether or not there isany handle indicating the code area or the data area to be shifted bythe compaction. If the handle indicating the code area or the data areawas found, the handle relocating program generating means generates thehandle relocating program for relocating this handle. After all thehandles are relocated, the compaction program generating means generatesthe compaction program for compacting the code area or the data area.Accordingly, the fragmentation of the memory can be solved, therebyenabling the effective use of the memory.

Further, the computer-readable storage medium storing the compilerprogram according to the present invention is the computer-readablestorage medium storing the compiler program for converting the sourceprogram into the object program and causing the computer to function asthe address saving program generating means for saving the addresssaving program for saving the data memory area address used by thecalling program module included in the source program; the addresssetting program generating means for generating the address settingprogram for setting the data memory area address used by the otherprogram module to be called by the calling program module; thetransferring program generating means for generating the transferringprogram for the transfer from the first subprogram included in thecalling program module to the second subprogram included in the otherprogram module; the address resetting program generating means forgenerating the address resetting program for reading and resetting thesaved data memory area address for the calling program module after thereturn from the second subprogram as the transfer end to the firstsubprogram; and the accessing program generating means for generatingthe accessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein.

With this storage medium, the address saving program generating meansgenerates the address saving program for saving the data memory areaaddress used by the calling program module included in the sourceprogram. The address setting program generating means generates theaddress setting program for setting the data memory area address used bythe other program module to be called by the calling program module.Further, the transferring program generating means generates thetransferring program for the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module. The address resetting program generating meansgenerates the address resetting program for reading and resetting thesaved data memory area address for the calling program module after thereturn from the second subprogram as the transfer end to the firstsubprogram. The accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Further, the compiling method according to the present invention is forconverting the source program into the object program and comprises theaddress saving program generating step of causing the computer to savethe address saving program for saving the data memory area address usedby the calling program module included in the source program; theaddress setting program generating step of causing the computer togenerate the address setting program for setting the data memory areaaddress used by the other program module to be called by the callingprogram module; the transferring program generating step of causing thecomputer to generate the transferring program for the transfer from thefirst subprogram included in the calling program module to the secondsubprogram included in the other program module; the address resettingprogram generating step of causing the computer to generate the addressresetting program for reading and resetting the saved data memory areaaddress for the calling program module after the return from the secondsubprogram as the transfer end to the first subprogram; and theaccessing program generating step of causing the computer to generatethe accessing program for accessing the data memory area using therelative address from the set data memory area address for the otherprogram module when the other program module accesses the data memoryarea therefor included therein.

With this method, the address saving program for saving the data memoryarea address used by the calling program module included in the sourceprogram is generated in the address saving program generating step. Theaddress setting program for setting the data memory area address used bythe other program module to be called by the calling program module isgenerated in the address setting program generating step. Further, thetransferring program for the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module is generated in the transferring program generatingstep. The address resetting program for reading and resetting the saveddata memory area address for the calling program module after the returnfrom the second subprogram as the transfer end to the first subprogramis generated in the address resetting program generating step. Theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein is generated inthe accessing program generating step.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Further, the compiling unit according to the present invention is forconverting the source program into the object program and comprises theaddress saving program generating means for saving the address savingprogram for saving the data memory area address used by the callingprogram module included in the source program; the address settingprogram generating means for generating the address setting program forsetting the data memory area address used by the other program module tobe called by the calling program module; the transferring programgenerating means for generating the transferring program for thetransfer from the first subprogram included in the calling programmodule to the second subprogram included in the other program module;the address resetting program generating means for generating theaddress resetting program for reading and resetting the saved datamemory area address for the calling program module after the return fromthe second subprogram as the transfer end to the first subprogram; andthe accessing program generating means for generating the accessingprogram for accessing the data memory area for the other program moduleusing the relative address from the set data memory area address for theother program module when the other program module accesses the datamemory area therefor included therein.

With this construction, the address saving program generating meansgenerates the address saving program for saving the data memory areaaddress used by the calling program module included in the sourceprogram. The address setting program generating means generates theaddress setting program for setting the data memory area address used bythe other program module to be called by the calling program module.Further, the transferring program generating means generates thetransferring program for the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module. The address resetting program generating meansgenerates the address resetting program for reading and resetting thesaved data memory area address for the calling program module after thereturn from the second subprogram as the transfer end to the firstsubprogram. The accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Further, the object program according to the present invention isgenerated by converting the source program and causes the computer tofunction as the address saving means for saving the data memory areaaddress used by the calling program module included in the sourceprogram; the address setting means for setting the data memory areaaddress used by the other program module to be called by the callingprogram module; the transferring means for executing the transfer fromthe first subprogram included in the calling program module to thesecond subprogram included in the other program module; the addressresetting means for reading and resetting the data memory area addressfor the calling program module saved by the address saving means afterthe return from the second subprogram as the transfer end of thetransferring means end to the first subprogram; and the accessing meansfor accessing the data memory area for the other program module usingthe relative address from the data memory area address for the otherprogram module set by the address setting means when the other programmodule accesses the data memory area therefor included therein.

With this configuration, the address saving means saves the data memoryarea address used by the calling program module included in the sourceprogram. The address setting means sets the data memory area addressused by the other program module to be called by the calling programmodule. Further, the transferring means executes the transfer from thefirst subprogram included in the calling program module to the secondsubprogram included in the other program module. The address resettingmeans reads and resets the data memory area address for the callingprogram module saved by the address saving means after the return fromthe second subprogram as the transfer end to the first subprogram. Theaccessing means accesses the data memory area for the other programmodule using the relative address from the set data memory area addressfor the other program module when the other program module accesses thedata memory area therefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Further, the computer-readable storage medium storing the compilerprogram according to the present invention is the computer-readablestorage medium storing the object program generated by converting thesource program and causing the computer to function as the addresssaving means for saving the data memory area address used by the callingprogram module included in the source program; the address setting meansfor setting the data memory area address used by the other programmodule to be called by the calling program module; the transferringmeans for executing the transfer from the first subprogram included inthe calling program module to the second subprogram included in theother program module; the address resetting means for reading andresetting the data memory area address for the calling program modulesaved by the address saving means after the return from the secondsubprogram as the transfer end of the transferring means to the firstsubprogram; and the accessing means for accessing the data memory areafor the other program module using the relative address from the datamemory area address for the other program module set by the addresssetting means when the other program module accesses the data memoryarea therefor included therein.

With this configuration, the address saving means saves the data memoryarea address used by the calling program module included in the sourceprogram. The address setting means sets the data memory area addressused by the other program module to be called by the calling programmodule. Further, the transferring means executes the transfer from thefirst subprogram included in the calling program module to the secondsubprogram included in the other program module. The address resettingmeans reads and resets the data memory area address for the callingprogram module saved by the address saving means after the return fromthe second subprogram as the transfer end to the first subprogram. Theaccessing means accesses the data memory area for the other programmodule using the relative address from the set data memory area addressfor the other program module when the other program module accesses thedata memory area therefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Further, the object program executing method according to the presentinvention is for executing the object program generated by convertingthe source program and comprises the address saving step of causing thecomputer to save the data memory area address used by the callingprogram module included in the source program; the address setting stepof causing the computer to set the data memory area address used by theother program module to be called by the calling program module; thetransferring step of causing the computer to execute the transfer fromthe first subprogram included in the calling program module to thesecond subprogram included in the other program module; the addressresetting step of causing the computer to read and reset the data memoryarea address for the calling program module saved by the address savingmeans after the return from the second subprogram as the transfer end inthe transferring step to the first subprogram; and the accessing step ofcausing the computer to access the data memory area for the otherprogram module using the relative address from the data memory areaaddress for the other program module set by the address setting meanswhen the other program module accesses the data memory area thereforincluded therein.

With this method, the data memory area address used by the callingprogram module included in the source program is saved in the addresssaving step. The data memory area address used by the other programmodule to be called by the calling program module is set in the addresssetting step. Further, the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module is executed in the transferring step. In theaddress resetting step, the saved data memory area address for thecalling program module is read and reset after the return from thesecond subprogram as the transfer end in the transferring step to thefirst subprogram. In the accessing step, the data memory area for theother program module is accessed using the relative address from the setdata memory area address for the other program module when the otherprogram module accesses the data memory area therefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

Further, the object program executing unit according to the presentinvention is for executing the object program generated by convertingthe source program and comprises the address saving means for saving thedata memory area address used by the calling program module included inthe source program; the address setting means for setting the datamemory area address used by the other program module to be called by thecalling program module; the transferring means for executing thetransfer from the first subprogram included in the calling programmodule to the second subprogram included in the other program module;the address resetting means for reading and resetting the data memoryarea address for the calling program module saved by the address savingmeans after the return from the second subprogram as the transfer end ofthe transferring means to the first subprogram; and the accessing meansfor accessing the data memory area for the other program module usingthe relative address from the data memory area address for the otherprogram module set by the address setting means when the other programmodule accesses the data memory area therefor included therein.

With this construction, the address saving means saves the data memoryarea address used by the calling program module included in the sourceprogram. The address setting means sets the data memory area addressused by the other program module to be called by the calling programmodule. Further, the transferring means executes the transfer from thefirst subprogram included in the calling program module to the secondsubprogram included in the other program module. The address resettingmeans reads and resets the saved data memory area address for thecalling program module after the return from the second subprogram asthe transfer end to the first subprogram. The accessing means accessesthe data memory area for the other program module using the relativeaddress from the set data memory area address for the other programmodule when the other program module accesses the data memory areatherefor included therein.

Accordingly, even if the calling program module reenters the otherprogram module, the data memory area address for the calling programmodule can be retracted since the data memory area address used by thecalling program module is saved, and the reentrant object program can begenerated since the data memory area address for the other programmodule to be called by the calling program module is set. Thus, dynamiclinks between the modules can be realized.

In the above object program executing unit, it is preferable that thecalling program module includes the code area and the data area; theother program module includes the code area and the data area; and theobject program executing unit further comprises theidentification-number designating means for designating theidentification number for identifying the calling program module and theone for identifying the other program module; the table preparing meansfor preparing the table relating the identification number of thecalling program module designated by the identification-numberdesignating means to the leading address of the data area of the callingprogram module and relating the identification number of the otherprogram module designated by the identification-number designating meansto the leading address of the data area of the other program module; theidentification-number obtaining means for obtaining the identificationnumber of the other program module upon the receipt of the call commandto the other program from the calling program module; theleading-address obtaining means for obtaining the leading address of thedata area of the other program module from the table prepared by thetable generating means using the identification number obtained by theidentification-number obtaining means as an index; and theleading-address switching means for switching the leading address of thedata area of the other program module obtained by the leading-addressobtaining means and the leading address of the data area of the callingprogram module.

With this construction, the calling program module includes the codearea and the data area; the other program module includes the code areaand the data area; and the identification-number designating meansdesignates the identification number for identifying the calling programmodule and the one for identifying the other program module. Then, thetable preparing means prepares the table relating the designatedidentification number of the calling program module to the leadingaddress of the data area of the calling program module and relating thedesignated identification number of the other program module to theleading address of the data area of the other program module. Theidentification-number obtaining means obtains the identification numberof the other program module upon the receipt of the call command to theother program from the calling program module. The leading-addressobtaining means obtains the leading address of the data area of theother program module from the table prepared by the table generatingmeans using the obtained identification number as an index. Theleading-address switching means switches the obtained leading address ofthe data area of the other program module and the leading address of thedata area of the calling program module.

Accordingly, by preparing the table for the address conversion not pageby page, but module by module, the amount of the data of the table canbe reduced and the table can conform to small-size apparatuses having astrict resource restriction.

Further, in the above object program executing unit, it is preferablethat the calling program module includes the code area and the dataarea; the other program module includes the code area and the data area;and the object program executing unit further comprises theidentification-number designating means for designating theidentification number for identifying the calling program module and theone for identifying the other program module; and the table preparingmeans for preparing the table relating the identification number of thecalling program module designated by the identification-numberdesignating means to the leading address of the data area of the callingprogram module and relating the identification number of the otherprogram module designated by the identification-number designating meansto the leading address of the data area of the other program module.

With this construction, the calling program module includes the codearea and the data area, the other program module includes the code areaand the data area, and the identification-number designating meansdesignates the identification number for identifying the calling programmodule and the one for identifying the other program module. Then, thetable preparing means for preparing the table relating the designatedidentification number of the calling program module to the leadingaddress of the data area of the calling program module and relating thedesignated identification number of the other program module to theleading address of the data area of the other program module.

Accordingly, by preparing the table for the address conversion not pageby page, but module by module, the amount of the data of the table canbe reduced and the table can conform to small-size apparatuses having astrict resource restriction.

Although the present invention has been described in detail, the abovedescription is only an example in all aspects and the present inventionis not limited thereto. It should be appreciated that countlessunillustrated modifications and embodiments can be supposed withoutdeparting from the scope of the present invention.

INDUSTRIAL APPLICABILITY

The compiler program, the computer-readable storage medium storing thecompiler program, the compiling method and the compiling unit accordingto the present invention enable the automatic generation of a reentrantobject program and are effectively usable as a compiler program, acomputer-readable storage medium storing the compiler program, acompiling method, a compiling unit and the like for converting a sourceprogram written in a certain program language into an object program tobe executed by a certain computer.

1. A computer-readable storage medium storing a compiler program forconverting a source program into an object program, the compiler programcausing a computer to function as: an address saving program generatingmeans for generating an address saving program for saving in a memory adata memory area address used by a calling program module included inthe source program, an address setting program generating means forgenerating an address setting program for setting a data memory areaaddress used by an other program module to be called by the callingprogram module, a transferring program generating means for generating atransferring program for the transfer from a first subprogram includedin the calling program module to a second subprogram included in theother program module, an address resetting program generating means forgenerating an address resetting program for reading and resetting thedata memory area address saved in the memory for the calling programmodule after the return from the second subprogram as a transfer end tothe first subprogram, and an accessing program generating means forgenerating an accessing program for accessing a data memory area for theother program module using a relative address from the set data memoryarea address for the other program module when the other program moduleaccesses the data memory area therefor included therein.
 2. Acomputer-readable storage medium storing a compiler program according toclaim 1, wherein: the computer is caused to further function as adiscriminating means for discriminating whether or not to shorten aprocess based on a description of the other program module including thesecond subprogram to be called from the first subprogram included in thecalling program module included in the source program, if thediscriminating means discriminates the process not to be shortened, theaddress saving program generating means generates the address savingprogram for saving the data memory area address used by the callingprogram module, the address setting program generating means generatesthe address setting program for setting the data memory area addressused by the other program module to be called by the calling programmodule, the transferring program generating means generates thetransferring program for the transfer from the first subprogram includedin the calling program module to the second subprogram included in theother program module, the address resetting program generating meansgenerates the address resetting program for reading and resetting thesaved data memory area address for the calling program module after thereturn from the second subprogram as the transfer end to the firstsubprogram, and the accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein, and if thediscriminating means discriminates the process to be shortened, thetransferring program generating means generates the transferring programfor the transfer from the first subprogram included in the callingprogram module to the second subprogram included in the other programmodule, and the accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the data memory areaaddress for the calling program module when the other program moduleaccesses the data memory area therefor included therein.
 3. Acomputer-readable storage medium storing a compiler program according toclaim 1, wherein, after the second subprogram included in the otherprogram module is called from the first subprogram included in thecalling program module included in the source program; the addresssetting program generating means generates an address setting programfor reading the data memory area address for the other program modulefrom data memory area address tables for the respective program modulessaved in executing units of the calling program module and setting thisdata memory area address, and the accessing program generating meansgenerates the accessing program for accessing the data memory area forthe other program module using the relative address from the set datamemory area address for the other program module when the other programmodule accesses the data memory area therefor included therein.
 4. Acomputer-readable storage medium storing a compiler program according toclaim 3, wherein the computer is caused to further function as adiscriminating means for discriminating whether or not to shorten aprocess based on a description of the other program module including thesecond subprogram to be called from the first subprogram included in thecalling program module included in the source program, if thediscriminating means discriminates the process not to be shortened,after the second subprogram included in the other program module iscalled from the first subprogram included in the calling program moduleincluded in the source program: the address setting program generatingmeans generates the address setting program for reading the data memoryarea address for the other program module from the data memory areaaddress tables for the respective program modules saved in executingunits of the calling program module and setting this data memory areaaddress, and the accessing program generating means generates theaccessing program for accessing the data memory area for the otherprogram module using the relative address from the set data memory areaaddress for the other program module when the other program moduleaccesses the data memory area therefor included therein, and if thediscriminating means discriminates the process to be shortened, theaccessing program generating means generates the accessing program foraccessing the data memory area for the other program module using therelative address from the data memory area address for the callingprogram module when the other program module accesses the data memoryarea therefor included therein.
 5. A computer-readable storage mediumstoring a compiler program according to claim 2, wherein the descriptionof the other program module including the second subprogram to be calledfrom the first subprogram included in the calling program moduleincluded in the source program is a declaration described for eachsecond subprogram.
 6. A computer-readable storage medium storing acompiler program according to claim 1, wherein the source programincluding the other program module including the second subprogram to becalled by the calling program module includes a description forspecifying which of an execution common data memory area for the otherprogram module external variables included in the other program modulecommonly access upon a plurality of executions of the calling programmodule and an execution intrinsic data memory areas for the otherprogram module the external variables included in the other programmodule commonly access every time the calling program module is executedis to be used.
 7. A computer-readable storage medium storing a compilerprogram according to claim 6, wherein the description for specifyingwhich of the execution common data memory area for the other programmodule and the execution intrinsic data memory area for the otherprogram module is to be used is a declaration described for eachexternal variable included in the other program module.
 8. Acomputer-readable storage medium storing a compiler program according toclaim 6, wherein: the address saving program generating means generatesan address saving program for saving an execution common data memoryarea address for the calling program module and an execution intrinsicdata memory area address for the calling program module, the addresssetting program generating means generates an address setting programfor setting the execution common data memory area address for the otherprogram module to be called by the calling program module and settingthe execution intrinsic data memory area address for the other programmodule to be called by the calling program module, the transferringprogram generating means generates the transferring program for thetransfer from the first subprogram to the second subprogram, the addressresetting program generating means generates an address resettingprogram for reading and resetting the saved execution intrinsic datamemory area address and execution common data memory area address forthe calling program module after the return from the second subprogramas the transfer end to the first subprogram, and the accessing programgenerating means generates an accessing program for accessing theexecution intrinsic data memory area for the other program using arelative address from the set execution intrinsic data memory areaaddress for the other program module when the other program moduleaccesses the execution intrinsic data memory area address thereforincluded therein and accessing the execution common data memory area forthe other program using a relative address from the set execution commondata memory area address for the other program module when the otherprogram module accesses the execution intrinsic data memory area addresstherefor included therein.
 9. A computer-readable storage medium storinga compiler program according to claim 6, wherein, after the otherprogram module is called from the calling program module included in thesource program: the address setting program generating means generatesan address setting program for reading the execution intrinsic datamemory area address for the other program module and the executioncommon data memory area address for the other program module commonlyaccessed by a plurality of executions of the calling program module fromthe data memory area address tables for the respective program modulessaved in executing units of the calling program module and setting thesedata memory area addresses, and the accessing program generating meansgenerates an accessing program for accessing the execution intrinsicdata memory area for the other program using a relative address from theset execution intrinsic data memory area address for the other programmodule when the other program module accesses the execution intrinsicdata memory area address therefor included therein and accessing theexecution common data memory area for the other program using a relativeaddress from the set execution common data memory area address for theother program module when the other program module accesses theexecution intrinsic data memory area address therefor included therein.10. A computer-readable storage medium storing a compiler programaccording to claim 1, wherein the address saving program generatingmeans generates an address saving program for saving the executioncommon data memory area address and the execution intrinsic data memoryarea address for the calling program module in a stack memory prior todata necessary for the transfer from the first subprogram to the secondsubprogram.
 11. A computer-readable storage medium storing a compilerprogram according to claim 1, wherein the calling program moduleincluded in the source program and the other program module includingthe second subprogram to be called from the first subprogram included inthe calling program module are the same program module.
 12. Acomputer-readable storage medium storing a compiler program according toclaim 1, wherein the calling program module includes a code area and adata area, the other program module includes a code area and a dataarea, and the computer is caused to further function as: anidentification-number obtaining program generating means for generatingan identification-number obtaining program for obtaining anidentification number for identifying the other program module upon thereceipt of a call command to the other program module from the callingprogram module, a leading-address obtaining program generating means forgenerating a leading-address obtaining program for obtaining the leadingaddress of the data area of the other program module using the obtainedidentification number as an index from a table relating anidentification number of the calling program module to the leadingaddress of the data area of the calling program module and relating theidentification number of the other program module to the leading addressof the data area of the other program module, and a leading-addressswitching program generating means for generating a leading-addressswitching program for switching the obtained leading address of the dataarea of the other program module and the leading address of the dataarea of the calling program module.
 13. A computer-readable storagemedium storing a compiler program according to claim 1, wherein thecalling program module includes a code area and a data area, the otherprogram module includes a code area and a data area, and the computer iscaused to further function as: an identification-number designatingprogram generating means for generating an identification-numbergenerating program for designating an identification number foridentifying the calling program module and an identification number foridentifying the other program module, a table preparing programgenerating means for generating a table preparing program for preparinga table relating the designated identification number of the callingprogram module to the leading address of the data area of the callingprogram module and relating the designated identification number of theother program module to the leading address of the data area of theother program module, an identification-number obtaining programgenerating means for generating an identification-number obtainingprogram for obtaining the identification number of the other programmodule upon the receipt of a call command to the other program modulefrom the calling program module, a leading-address obtaining programgenerating means for generating a leading-address obtaining program forobtaining the leading address of the data area of the other programmodule from the prepared table using the obtained identification numberas an index, and a leading-address switching program generating meansfor generating a leading-address switching program for switching theobtained leading address of the data area of the other program moduleand the leading address of the data area of the calling program module.14. A computer-readable storage medium storing a compiler programaccording to claim 1, wherein the computer is caused to further functionas an address latching program generating means for generating anaddress latching program for latching an address of a variable orfunction defined outside the other program module, and the accessingprogram generating means generates an accessing program for accessing avariable defined inside the other program module using a relativeaddress from the obtained leading address, accesses a function definedinside the other program module using a relative address from a programcounter, and indirectly accessing the variable or function definedoutside the other program module via the latched address after accessingthe latched address using a relative address from the obtained leadingaddress.
 15. A computer-readable storage medium storing a compilerprogram according to claim 1, wherein the computer is caused to furtherfunction as: an ending program generating means for generating an endingprogram for ending an application comprised of at least one module andbeing presently executed, a compaction program generating means forgenerating a compaction program for compacting a memory after theapplication is ended, and a resuming program generating means forgenerating a resuming program for resuming the application from thebeginning after the memory is compacted.
 16. A computer-readable storagemedium storing a compiler program according to claim 1, wherein thecomputer is caused to further function as: an ending program generatingmeans for generating an ending program for ending an applicationcomprised of at least one module and being presently executed, a savingprogram generating means for generating a saving program for savinginformation independent of address values of the application until theapplication was ended, a compaction program generating means forgenerating a compaction program for compacting a memory, and anexecuting program generating means for generating an executing programfor reading the saved information and executing the application up to astate where the application was ended based on the read informationafter the memory is compacted.
 17. A computer-readable storage mediumstoring a compiler program according to claim 1, wherein an identifierindicating whether or not to save an address value is provided in amemory, and the computer is caused to further function as: amemory-state saving program generating means for generating a memorystate saving program for saving the state of the memory before thecompaction, a compaction program generating means for generating acompaction program for compacting the memory, and a relocating programgenerating means for generating a relocating program for relocating theaddress value based on the identifier for an entry having the addressvalue set by referring to the saved state of the memory before thecompaction, after the memory is compacted.
 18. A computer-readablestorage medium storing a compiler program according to claim 1, whereinan address-value memory for saving address values and anon-address-value memory for saving values other than address values areprovided, and the computer is caused to further function as: amemory-state saving program generating means for generating amemory-state saving program for saving the states of the address-valuememory and the non-address-value memory before the compaction, acompaction program generating means for generating a compaction programfor compacting the address-value memory and the non-address-value, arelocating program generating means for generating a relocating programfor relocating the address values of only the address-value memory byreferring to the saved state of the address-value memory before thecompaction, after the address-value memory and the non-address-valuememory are compacted.
 19. A computer-readable storage medium storing acompiler program according to claim 1, wherein identification numbersfor identifying the modules and identifiers indicating whether to setaddresses of data areas of the modules or to set addresses of code areasof the modules are provided in a memory, and the computer is caused tofurther function as: a setting program generating means for generating asetting program for setting the identification number and the identifierupon substituting an address value for a pointer, a compaction programgenerating means for generating a compaction program for compacting thememory, and a recalculating program generating means for generating arecalculating program for recalculating the address value based on theidentification number and the identifier after the memory is compacted.20. A computer-readable storage medium storing a compiler programaccording to claim 1, wherein identification numbers for identifying themodules and identifiers indicating whether to set addresses of dataareas of the modules or to set addresses of code areas of the modulesare provided in a memory, and the computer is caused to further functionas: an offset-value setting program generating means for generating anoffset-value setting program for setting the identification number andthe identifier upon substituting an address value for a pointer andsetting an offset value from the leading address of the data area or theleading address of the code area, and an actual-address convertingprogram generating means for generating an actual-address convertingprogram for the conversion into an actual address by adding the leadingaddress of the data area or the leading address of the code area to theoffset value upon using the pointer.
 21. A computer-readable storagemedium storing a compiler program according to claim 1, wherein thecomputer is caused to further function as: a compaction programgenerating means for generating a compaction program for compacting eachcode area of the modules or each data area of the modules, a searchingprogram generating means for generating a searching program forsearching whether or not there is any handle indicating the code area orthe data area shifted by the compaction, and a handle relocating programgenerating means for generating a handle relocating program forrelocating the handle if the handle indicating the code area or the dataarea is found, wherein the compaction program generating means generatesthe compaction program for compacting the code areas or the data areasafter all the handles are relocated.
 22. A compiling method implementedby a compiling unit comprising a program storage and a program executingunit for converting a source program into an object program, thecompiling method comprising: a step of causing a computer to generate anaddress saving program for saving in a memory a data memory area addressused by a calling program module included in the source program, a stepof causing the computer to generate an address setting program forsetting a data memory area address used by an other program module to becalled by the calling program module, a step of causing the computer togenerate a transferring program for the transfer from a first subprogramincluded in the calling program module to a second subprogram includedin the other program module, a step of causing the computer to generatean address resetting program for reading and resetting the data memoryarea address saved in the memory for the calling program module afterthe return from the second subprogram as a transfer end to the firstsubprogram, and a step of causing the computer to generate an accessingprogram for accessing a data memory area for the other program moduleusing a relative address from the set data memory area address for theother program module when the other program module accesses the datamemory area therefor included therein.
 23. A compiling unit forconverting a source program into an object program, the compiling unitcomprising: a program storage; and a program executing unit comprising:an address saving program generating means for generating an addresssaving program for saving in a memory a data memory area address used bya calling program module included in the source program, an addresssetting program generating means for generating an address settingprogram for setting a data memory area address used by an other programmodule to be called by the calling program module, a transferringprogram generating means for generating a transferring program for thetransfer from a first subprogram included in the calling program moduleto a second subprogram included in the other program module, an addressresetting program generating means for generating an address resettingprogram for reading and resetting the saved data memory area addresssaved in the memory for the calling program module after the return fromthe second subprogram as a transfer end to the first subprogram, and anaccessing program generating means for generating an accessing programfor accessing a data memory area for the other program module using arelative address from the set data memory area address for the otherprogram module when the other program module accesses the data memoryarea therefor included therein.
 24. A computer-readable storage mediumstoring an object program generated by converting a source program andcausing a computer to functions as: an address saving means for savingin a memory a data memory area address used by a calling program moduleincluded in the source program, an address setting means for setting adata memory area address used by an other program module to be called bythe calling program module, a transferring means for executing thetransfer from a first subprogram included in the calling program moduleto a second subprogram included in the other program module, an addressresetting means for reading and resetting the data memory area addresssaved in the memory for the calling program module after the return fromthe second subprogram as a transfer end to the first subprogram, and anaccessing means for accessing a data memory area for the other programmodule using a relative address from the set data memory area addressfor the other program module when the other program module accesses thedata memory area therefor included therein.
 25. An object programexecuting method implemented by a computing unit comprising a programstorage and an object program executing unit for executing an objectprogram generated by converting a source program, the object programexecuting method comprising: an address saving step of causing acomputer to save in a memory a data memory area address used by acalling program module included in the source program, an addresssetting step of causing the computer to set a data memory area addressused by an other program module to be called by the calling programmodule, a transferring step of causing the computer to execute thetransfer from a first subprogram included in the calling program moduleto a second subprogram included in the other program module, an addressresetting step of causing the computer to read and reset the-saved datamemory area address saved in the memory for the calling program moduleafter the return from the second subprogram as a transfer end to thefirst subprogram, and an accessing step of causing the computer toaccess a data memory area for the other program module using a relativeaddress from the set data memory area address for the other programmodule when the other program module accesses the data memory areatherefor included therein.
 26. An-A computing unit comprising: a programstorage; and an object program executing unit for executing an objectprogram generated by converting a source program, the object programexecuting unit comprising: an address saving means for saving in amemory a data memory area address used by a calling program moduleincluded in the source program, an address setting means for setting adata memory area address used by an other program module to be called bythe calling program module, a transferring means for executing thetransfer from a first subprogram included in the calling program moduleto a second subprogram included in the other program module, an addressresetting means for reading and resetting the-saved data memory areaaddress saved in the memory for the calling program module after thereturn from the second subprogram as a transfer end to the firstsubprogram, and an accessing means for accessing a data memory area forthe other program module using a relative address from the set datamemory area address for the other program module when the other programmodule accesses the data memory area therefor included therein.
 27. Acomputing unit according to claim 26, wherein the calling program moduleincludes a code area and a data area, the other program module includesa code area and a data area, and the object program executing unitfurther comprises: an identification-number designating means fordesignating an identification number for identifying the calling programmodule and an identification number for identifying the other programmodule, a table preparing means for preparing a table relating theidentification number of the calling program module designated by theidentification-number designating means to the leading address of thedata area of the calling program module and relating the identificationnumber of the other program module designated by theidentification-number designating means to the leading address of thedata area of the other program module, an identification-numberobtaining means for obtaining the identification number of the otherprogram module upon the receipt of a call command to the other programmodule from the calling program module, a leading-address obtainingmeans for obtaining the leading address of the data area of the otherprogram module from the table prepared by the table preparing meansusing the identification number obtained by the identification-numberobtaining means as an index, and a leading-address switching means forswitching the leading address of the data area of the other programmodule obtained by the leading-address obtaining means and the leadingaddress of the data area of the calling program module.
 28. A computingunit according to claim 26, wherein the calling program module includesa code area and a data area, the other program module includes a codearea and a data area, and the object program executing unit furthercomprises: an identification-number designating means for designating anidentification number for identifying the calling program module and anidentification number for identifying the other program module, and atable preparing means for preparing a table relating the identificationnumber of the calling program module designated by theidentification-number designating means to the leading address of thedata area of the calling program module and relating the identificationnumber of the other program module designated by theidentification-number designating means to the leading address of thedata area of the other program module.
 29. A computer-readable storagemedium storing a compiler program according to claim 4, whereins thedescription of the other program module including the second subprogramto be called from the first subprogram included in the calling programmodule included in the source program is a declaration described foreach second subprogram.